Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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
Add Comment
Please, Sign In to add comment