class Net::SSH::Config
def translate(settings)
+settings+ hash must have Strings for keys, all downcased, and
a hash of Net::SSH options. Unrecognized options are ignored. The
Given a hash of OpenSSH configuration options, converts them into
def translate(settings) auth_methods = default_auth_methods.clone (auth_methods << 'challenge-response').uniq! ret = settings.inject({:auth_methods=>auth_methods}) do |hash, (key, value)| case key when 'bindaddress' then hash[:bind_address] = value when 'ciphers' then hash[:encryption] = value.split(/,/) when 'compression' then hash[:compression] = value when 'compressionlevel' then hash[:compression_level] = value when 'connecttimeout' then hash[:timeout] = value when 'forwardagent' then hash[:forward_agent] = value when 'identitiesonly' then hash[:keys_only] = value when 'globalknownhostsfile' hash[:global_known_hosts_file] = value when 'hostbasedauthentication' then if value (hash[:auth_methods] << "hostbased").uniq! else hash[:auth_methods].delete("hostbased") end when 'hostkeyalgorithms' then hash[:host_key] = value.split(/,/) when 'hostkeyalias' then hash[:host_key_alias] = value when 'hostname' then hash[:host_name] = value.gsub(/%h/, settings['host']) when 'identityfile' then hash[:keys] = value when 'macs' then hash[:hmac] = value.split(/,/) when 'serveralivecountmax' hash[:keepalive_maxcount] = value.to_i if value when 'serveraliveinterval' if value && value.to_i > 0 hash[:keepalive] = true hash[:keepalive_interval] = value.to_i else hash[:keepalive] = false end when 'passwordauthentication' if value (hash[:auth_methods] << 'password').uniq! else hash[:auth_methods].delete('password') end when 'challengeresponseauthentication' if value (hash[:auth_methods] << 'challenge-response').uniq! else hash[:auth_methods].delete('challenge-response') end when 'kbdinteractiveauthentication' if value (hash[:auth_methods] << 'keyboard-interactive').uniq! else hash[:auth_methods].delete('keyboard-interactive') end when 'port' hash[:port] = value when 'preferredauthentications' hash[:auth_methods] = value.split(/,/) # TODO we should place to preferred_auth_methods rather than auth_methods when 'proxycommand' if value and !(value =~ /^none$/) require 'net/ssh/proxy/command' hash[:proxy] = Net::SSH::Proxy::Command.new(value) end when 'pubkeyauthentication' if value (hash[:auth_methods] << 'publickey').uniq! else hash[:auth_methods].delete('publickey') end when 'rekeylimit' hash[:rekey_limit] = interpret_size(value) when 'user' hash[:user] = value when 'userknownhostsfile' hash[:user_known_hosts_file] = value when 'sendenv' multi_send_env = value.to_s.split(/\s+/) hash[:send_env] = multi_send_env.map { |e| Regexp.new pattern2regex(e).source, false } when 'numberofpasswordprompts' hash[:number_of_password_prompts] = value.to_i end hash end merge_challenge_response_with_keyboard_interactive(ret) end