Method: EventMachine::Ssh.connect

Defined in:
lib/em-ssh.rb

.connect(host, user, opts = {}) {|Session| ... } ⇒ Session Also known as: start

Connect to an ssh server

Examples:

EM::Ssh.start(host, user, options) do |connection|
 log.debug "**** connected: #{connection}"
 connection.open_channel do |channel|
   log.debug "**** channel: #{channel}"
   channel.request_pty(options[:pty] || {}) do |pty,suc|

Parameters:

  • host (String)
  • user (String)
  • opts (Hash) (defaults to: {})

    all options accepted by Net::SSH.start

Yields:

  • (Session)

    an EventMachine compatible Net::SSH::Session

Returns:

See Also:



116
117
118
119
120
121
122
123
124
125
126
# File 'lib/em-ssh.rb', line 116

def connect(host, user, opts = {}, &blk)
  opts[:logger] || logger.debug("#{self}.connect(#{host}, #{user}, #{opts})")

  options = {
    host: host,
    user: user,
    port: DEFAULT_PORT
  }.merge(opts)

  EM.connect(options[:host], options[:port], Connection, options, &blk)
end