Class Net::SSH::Authentication::Methods::Password

  1. lib/net/ssh/authentication/methods/password.rb

Implements the “password” SSH authentication method.

Methods

public instance

  1. authenticate

Public instance methods

authenticate (next_service, username, password=nil)

Attempt to authenticate the given user for the given service. If the password parameter is nil, this will never do anything except return false.

[show source]
    # File lib/net/ssh/authentication/methods/password.rb, line 14
14:           def authenticate(next_service, username, password=nil)
15:             return false unless password
16: 
17:             send_message(userauth_request(username, next_service, "password", false, password))
18:             message = session.next_message
19: 
20:             case message.type
21:               when USERAUTH_SUCCESS
22:                 debug { "password succeeded" }
23:                 return true
24:               when USERAUTH_FAILURE
25:                 debug { "password failed" }
26:                 return false
27:               when USERAUTH_PASSWD_CHANGEREQ
28:                 debug { "password change request received, failing" }
29:                 return false
30:               else
31:                 raise Net::SSH::Exception, "unexpected reply to USERAUTH_REQUEST: #{message.type} (#{message.inspect})"
32:             end
33:           end