Method: Fog::SCP::Real#initialize

Defined in:
lib/fog/core/scp.rb

#initialize(address, username, options) ⇒ Real

Returns a new instance of Real.



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/fog/core/scp.rb', line 46

def initialize(address, username, options)
  require 'net/scp'

  key_manager = Net::SSH::Authentication::KeyManager.new(nil, options)

  unless options[:key_data] || options[:keys] || options[:password] || key_manager.agent
    raise ArgumentError.new(':key_data, :keys, :password or a loaded ssh-agent is required to initialize SSH')
  end

  if options[:key_data] || options[:keys]
    options[:keys_only] = true
    #Explicitly set these so net-ssh doesn't add the default keys
    #as seen at https://github.com/net-ssh/net-ssh/blob/master/lib/net/ssh/authentication/session.rb#L131-146
    options[:keys] = [] unless options[:keys]
    options[:key_data] = [] unless options[:key_data]
  end

  @address  = address
  @username = username
  @options  = { :paranoid => false }.merge(options)
end