Sha256: 4d4fc0f1989e9228998117e202fc60501b3f916e952175b7658461f8a3a94cd1
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).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.5 | lib/quickmox/ssh_transport.rb |
quickmox-0.2.4 | lib/quickmox/ssh_transport.rb |