Sha256: a72fec7a837563ff25cc91e77f00932a00fcaf2a06610545dc8ba09a524a2098
Contents?: true
Size: 1.02 KB
Versions: 2
Compression:
Stored size: 1.02 KB
Contents
module Quickmox class SSHTransport class SSHTransportError < StandardError end attr_accessor :session, :host, :user, :pass def initialize(host, user, pass) @host = host @user = user @pass = pass end def connect handle_exceptions do @session = Net::SSH.start(host, user, password: pass, auth_methods: %w(password), number_of_password_prompts: 0, timeout: 3, paranoid: false) end self end def close handle_exceptions do session.close end end def exec!(cmd) handle_exceptions do session.exec!(cmd).to_s.chomp end end private def handle_exceptions begin yield rescue => e raise SSHTransportError, "Exception while talking to host #{host}: #{e}" end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
quickmox-0.2.8b | lib/quickmox/ssh_transport.rb |
quickmox-0.2.8 | lib/quickmox/ssh_transport.rb |