Class: SSHConnection

Inherits:
Object
  • Object
show all
Defined in:
lib/ssh_connection.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ SSHConnection

Returns a new instance of SSHConnection.



4
5
6
# File 'lib/ssh_connection.rb', line 4

def initialize(config)    
  @connection = Net::SSH.start(config[:host], config[:username], :password => config[:password])
end

Instance Attribute Details

#debugObject

Returns the value of attribute debug.



2
3
4
# File 'lib/ssh_connection.rb', line 2

def debug
  @debug
end

Instance Method Details

#send_command(commandstr) ⇒ Object



8
9
10
11
12
13
14
# File 'lib/ssh_connection.rb', line 8

def send_command(commandstr)
  if !@debug
    @connection.exec! commandstr
  else
    puts "command: #{commandstr}"
  end
end