class Rake::SSH
Public Class Methods
tunnel() { |local, host, port| ... }
click to toggle source
# File lib/rake/pro/ssh_tunnel.rb, line 84 def tunnel host = gateway = port = jump = nil cfg = Rake.application.cfg.values if cfg.has_key?(:jumpbox) jump = cfg[:jumpbox] gateway = Net::SSH::Gateway.new( jump[:host], jump[:user], :keys => [jump[:keyfile]] #, :verbose => :debug ) host = "127.0.0.1" port = gateway.open(cfg[:host], cfg[:port], jump[:port]) else host = cfg[:host] port = cfg[:port] end local = Rake::Local.new yield(local, host, port) if block_given? rescue Net::SSH::AuthenticationFailed => ex puts "\nError: SSH Failed to Authenticate. You may need to run\n $ ssh-add ~/.ssh/#{jump[:keyfile]} # key file\n ** or add this line to your .bashrc.\n\n" ensure gateway.close(port) unless gateway.nil? end