lib/net/ssh/config.rb in net-ssh-net-ssh-2.0.12 vs lib/net/ssh/config.rb in net-ssh-net-ssh-2.0.13
- old
+ new
@@ -55,15 +55,16 @@
# #translate for how to convert the OpenSSH options into Net::SSH
# options.)
def load(file, host, settings={})
file = File.expand_path(file)
return settings unless File.readable?(file)
-
- in_match = false
+
+ matched_host = nil
+ multi_host = []
IO.foreach(file) do |line|
next if line =~ /^\s*(?:#.*)?$/
-
+
if line =~ /^\s*(\S+)\s*=(.*)$/
key, value = $1, $2
else
key, value = line.strip.split(/\s+/, 2)
end
@@ -80,20 +81,23 @@
when /^yes$/i then true
else value
end
if key == 'host'
- in_match = (host =~ pattern2regex(value))
- elsif in_match
+ # Support "Host host1,host2,hostN".
+ # See http://github.com/net-ssh/net-ssh/issues#issue/6
+ multi_host = value.split(/,\s+/)
+ matched_host = multi_host.select { |h| host =~ pattern2regex(h) }.first
+ elsif !matched_host.nil?
if key == 'identityfile'
settings[key] ||= []
settings[key] << value
else
settings[key] = value unless settings.key?(key)
end
end
end
-
+
return settings
end
# Given a hash of OpenSSH configuration options, converts them into
# a hash of Net::SSH options. Unrecognized options are ignored. The
\ No newline at end of file