Method: Capistrano::SSH.connect

Defined in:
lib/capistrano/ssh.rb

.connect(server, options = {}) ⇒ Object

An abstraction to make it possible to connect to the server via public key without prompting for the password. If the public key authentication fails this will fall back to password authentication.

server must be an instance of ServerDefinition.

If a block is given, the new session is yielded to it, otherwise the new session is returned.

If an :ssh_options key exists in options, it is passed to the Net::SSH constructor. Values in options are then merged into it, and any connection information in server is added last, so that server info takes precedence over options, which takes precendence over ssh_options.



39
40
41
42
43
44
# File 'lib/capistrano/ssh.rb', line 39

def self.connect(server, options={})
  connection_strategy(server, options) do |host, user, connection_options|
    connection = Net::SSH.start(host, user, connection_options)
    Server.apply_to(connection, server)
  end
end