Sha256: fb93a940182aab776b96cfd15b3a99b90a49a6121fb92cf4991aa81062b21287
Contents?: true
Size: 1.13 KB
Versions: 19
Compression:
Stored size: 1.13 KB
Contents
require "net/ssh" # The main Smartcloud SSH driver module Smartcloud class SSH < Smartcloud::Base def initialize end def run(*commands) commands.flatten! Net::SSH.start(Smartcloud.credentials.machine[:host], Smartcloud.credentials.machine[:username], { port: Smartcloud.credentials.machine[:port], password: Smartcloud.credentials.machine[:password] }) do |ssh| channel = ssh.open_channel do |channel, success| channel.request_pty do |channel, success| channel.exec commands.join(';') do |channel, success| raise "Could not execute command" unless success channel.on_data do |channel, data| $stdout.print data if data =~ /^\[sudo\] password for / channel.send_data "#{Smartcloud.credentials.machine[:password]}\n" end end channel.on_extended_data do |channel, type, data| $stderr.print data end channel.on_close do |channel| # puts "done!" end end end end channel.wait end end def login exec "ssh #{Smartcloud.credentials.machine[:username]}@#{Smartcloud.credentials.machine[:host]}" end end end
Version data entries
19 entries across 19 versions & 1 rubygems