class EventMachine::Ssh

@example

 EM::Ssh.start(host, user, :password => password) do |ssh|
  ssh.exec("hostname") do |ch,stream,data|
    puts "data: #{data}"
  end
end

Constants

DEFAULT_PORT
VERSION

Attributes

logger[W]

Private Class Methods

connect(host, user, opts = {}, &blk) click to toggle source

Connect to an ssh server @param [String] host @param [String] user @param [Hash] opts all options accepted by Net::SSH.start @yield [Session] an EventMachine compatible Net::SSH::Session @see net-ssh.github.com/ssh/v2/api/index.html @return [Session] @example

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|
# 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
Also aliased as: start
logger(level = Logger::WARN) click to toggle source

Creates a logger when necessary @return [Logger]

# File lib/em-ssh.rb, line 99
def logger(level = Logger::WARN)
  @logger ||= ::Logger.new(STDERR).tap{ |l| l.level = level }
end
start(host, user, opts = {}, &blk)
Alias for: connect