1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

Make :key_data, :keys and :password optional in Fog::SSH.new

Net::SSH 2.0 will automatically authenticate with ssh-agent if it's
running, so a key or password is only required if ENV['SSH_AUTH_SOCK']
is not set.

See https://github.com/net-ssh/net-ssh/blob/v2.0.0/lib/net/ssh/authentication/key_manager.rb#L20-23
This commit is contained in:
Tom Stuart 2011-01-22 17:01:13 +08:00 committed by Wesley Beary
parent e53fffeb28
commit 4bfe1a27c7

View file

@ -2,8 +2,8 @@ module Fog
module SSH
def self.new(address, username, options = {})
unless options[:key_data] || options[:keys] || options[:password]
raise ArgumentError.new(':key_data, :keys or :password are required to initialize SSH')
unless options[:key_data] || options[:keys] || options[:password] || ENV['SSH_AUTH_SOCK']
raise ArgumentError.new(':key_data, :keys, :password or ENV[\'SSH_AUTH_SOCK\'] are required to initialize SSH')
end
if Fog.mocking?
Fog::SSH::Mock.new(address, username, options)