Method: Open4ssh.capture
- Defined in:
- lib/open4ssh.rb
.capture(host: '', user: '', port: 22, key: '', pwd: '', cmd: '') ⇒ String
Executes a shell command on a remote host via SSH and captures the console output.
51 52 53 54 55 56 57 58 59 60 |
# File 'lib/open4ssh.rb', line 51 def self.capture(host: '', user: '', port: 22, key: '', pwd: '', cmd: '') stdout = "" keys = [key] Net::SSH.start(host, user, port: port, password: pwd, keys: keys, paranoid: false) do |ssh| stdout = ssh.exec!(cmd) end return stdout end |