Class: Yads::SSH
- Inherits:
-
Object
- Object
- Yads::SSH
- Defined in:
- lib/yads/ssh.rb
Instance Method Summary collapse
- #close ⇒ Object
- #execute(cmd) ⇒ Object
-
#initialize(config) ⇒ SSH
constructor
A new instance of SSH.
Constructor Details
#initialize(config) ⇒ SSH
Returns a new instance of SSH.
7 8 9 10 11 12 |
# File 'lib/yads/ssh.rb', line 7 def initialize(config) = { :forward_agent => config[:forward_agent] } [:port] = config[:port] if config[:port] @ssh = Net::SSH.start(config[:host], config[:user], ) end |
Instance Method Details
#close ⇒ Object
25 26 27 |
# File 'lib/yads/ssh.rb', line 25 def close @ssh.close end |
#execute(cmd) ⇒ Object
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/yads/ssh.rb', line 14 def execute(cmd) if block_given? @ssh.exec(cmd) do |ch, stream, data| yield data end @ssh.loop else @ssh.exec!(cmd) end end |