119: def translate(settings)
120: settings.inject({}) do |hash, (key, value)|
121: case key
122: when 'ciphers' then
123: hash[:encryption] = value.split(/,/)
124: when 'compression' then
125: hash[:compression] = value
126: when 'compressionlevel' then
127: hash[:compression_level] = value
128: when 'connecttimeout' then
129: hash[:timeout] = value
130: when 'forwardagent' then
131: hash[:forward_agent] = value
132: when 'identitiesonly' then
133: hash[:keys_only] = value
134: when 'globalknownhostsfile'
135: hash[:global_known_hosts_file] = value
136: when 'hostbasedauthentication' then
137: if value
138: hash[:auth_methods] ||= []
139: hash[:auth_methods] << "hostbased"
140: end
141: when 'hostkeyalgorithms' then
142: hash[:host_key] = value.split(/,/)
143: when 'hostkeyalias' then
144: hash[:host_key_alias] = value
145: when 'hostname' then
146: hash[:host_name] = value
147: when 'identityfile' then
148: hash[:keys] = value
149: when 'macs' then
150: hash[:hmac] = value.split(/,/)
151: when 'passwordauthentication'
152: if value
153: hash[:auth_methods] ||= []
154: hash[:auth_methods] << "password"
155: end
156: when 'port'
157: hash[:port] = value
158: when 'preferredauthentications'
159: hash[:auth_methods] = value.split(/,/)
160: when 'proxycommand'
161: if value and !(value =~ /^none$/)
162: require 'net/ssh/proxy/command'
163: hash[:proxy] = Net::SSH::Proxy::Command.new(value)
164: end
165: when 'pubkeyauthentication'
166: if value
167: hash[:auth_methods] ||= []
168: hash[:auth_methods] << "publickey"
169: end
170: when 'rekeylimit'
171: hash[:rekey_limit] = interpret_size(value)
172: when 'user'
173: hash[:user] = value
174: when 'userknownhostsfile'
175: hash[:user_known_hosts_file] = value
176: end
177: hash
178: end
179: end