1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00
fog--fog/lib/fog/ssh.rb
2010-04-14 20:32:56 -07:00

31 lines
756 B
Ruby

module Fog
class SSH
def initialize(address, username, options = {})
unless options[:keys] || options[:password]
raise ArgumentError.new(':keys or :password are required to initialize SSH')
end
@address = address
@username = username
@options = options.merge!(:paranoid => false)
end
def run(commands)
commands = [*commands]
results = []
Net::SSH.start(@address, @username, @options) do |ssh|
commands.each do |command|
result = { :command => command }
ssh.exec!("bash -lc #{command.inspect}") do |channel, stream, data|
result[stream] = data
end
results << result
end
end
results
end
end
end