Created
July 17, 2009 22:02
-
-
Save royw/149302 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def connect | |
if @ssh.nil? | |
# @password => {:password=>"..."} if a password is provided, otherwise => {} | |
options = @password.merge({ | |
:timeout=>2, | |
# :auth_methods => %w(publickey hostbased password, keyboard-interactive) | |
:auth_methods => %w(publickey hostbased password) | |
}) | |
options = @password.merge({:verbose=>Logger::DEBUG}) if @choices[:ssh_debug] | |
@logger.debug { "connect: @machine=>#{@machine}, @user=>#{@user}, options=>#{options.inspect}" } | |
begin | |
@ssh = Net::SSH.start(@machine, @user, options) | |
# @ssh.forward.local(@port, @machine, @port) | |
rescue Net::SSH::AuthenticationFailed | |
@logger.error { "connect raised Net::SSH::AuthenticationFailed" } | |
@ssh = nil | |
raise Net::SSH::AuthenticationFailed.new(@name) | |
rescue Exception => e | |
@logger.error { "connect raised #{e}"} | |
@ssh = nil | |
raise e | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment