Sha256: ad079bb647c7b63a8a1e94b3998f3582695723bccdf4305fbb2252c79832dd33
Contents?: true
Size: 1.76 KB
Versions: 1
Compression:
Stored size: 1.76 KB
Contents
module Publisher class Ssh attr_accessor :remote_user attr_accessor :remote_host attr_accessor :ssh_key_file def remote_execute(command) Helper.validates_presence_of remote_user, "Remote User not set" Helper.validates_presence_of remote_host, "Remote Host not set" Helper.validates_presence_of ssh_key_file, "SSH keyfile not set" Helper.validates_presence_of command, "No valid remote command given" result = '' # joined_filename = File.join(File.dirname($exec_file_path), ssh_key_file) # ssh_key_file = joined_filename if not File.file? ssh_key_file $log.writer.error "Can not find SSH keyfile #{ssh_key_file}" exit 1 end Net::SSH.start(remote_host, remote_user, \ :auth_methods => ['publickey'], \ :forward_agent => true, \ :keys => ssh_key_file, \ :timeout => 30 ) do |session| session.open_channel do |ch| ch.exec command do |ch, success| if not success $log.writer.error "Can not execute remote command: '#{command}'" exit 1 end ch.on_data do |ch, data| if data.empty? $log.writer.debug "Command successfully executed" else $log.writer.debug data end end ch.on_extended_data do |ch, type, data| $log.writer.error "could not execute command" $log.writer.error data exit 1 end ch.on_close do |ch| # result << "all done, closing!" end end end end result end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
depengine-0.0.12 | lib/depengine/publisher/ssh.rb |