| Class | Net::SSH::UserAuth::Methods::Password |
| In: |
lib/net/ssh/userauth/methods/password.rb
|
| Parent: | Object |
Implements the "password" SSH authentication method.
| messenger | [W] | The messenger to use when communicating. |
Attempt to authenticate the given user for the given service. The data hash must specify a :password value, otherwise this will always return false.
# File lib/net/ssh/userauth/methods/password.rb, line 41
41: def authenticate( next_service, username, data={} )
42: return false unless data[:password]
43:
44: msg = @buffers.writer
45: msg.write_byte USERAUTH_REQUEST
46: msg.write_string username
47: msg.write_string next_service
48: msg.write_string "password"
49: msg.write_bool false
50: msg.write_string data[:password]
51: @messenger.send_message msg
52:
53: message = @messenger.wait_for_message
54:
55: case message.message_type
56: when USERAUTH_SUCCESS
57: return true
58: when USERAUTH_FAILURE, USERAUTH_PASSWD_CHANGEREQ
59: return false
60: else
61: raise Net::SSH::Exception,
62: "unexpected reply to USERAUTH_REQUEST: #{message.inspect}"
63: end
64: end