Sha256: 0ce871d9df21e8f631ab10feeea38a5c365dc261c7745db6f7f3fe992cfd3b7b

Contents?: true

Size: 1.09 KB

Versions: 6

Compression:

Stored size: 1.09 KB

Contents

require 'albacore/support/albacore_helper'
require 'net/ssh'

class Ssh
  extend AttrMethods
  include YAMLConfig
  include Logging
  
  attr_accessor :server, :username, :password, :port, :key, :debug
  attr_array :commands
    
  def initialize
    @commands = []
    super()
  end
  
    def get_connection_options
    options = {}
    options[:verbose] = :debug if @debug == true
    options[:password] = @password if @password
    options[:port] = @port if @port
    options[:keys] = [@key] if @key
    options
  end
  
  def execute()
    warn_about_key if @key
    
    Net::SSH.start(@server, @username, get_connection_options) do |ssh|
      @commands.each{|cmd|
        @logger.info "Executing remote command: #{cmd}"
        output = ssh.exec!(cmd)
        @logger.info 'SSH output: '
        @logger.info output
      }
    end
  end
  
  def warn_about_key()
    info.debug 'When using a key, you need an SSH-Agent running to manage the keys.'
    info.debug 'On Windows, a recommended agent is called Pageant, downloadable from the Putty site.'
  end
  
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
albacore-0.1.5 lib/albacore/ssh.rb
albacore-0.1.4 lib/albacore/ssh.rb
albacore-0.1.3 lib/albacore/ssh.rb
albacore-0.1.2 lib/albacore/ssh.rb
albacore-0.1.1 lib/albacore/ssh.rb
albacore-0.1.0 lib/albacore/ssh.rb