Implements the "keyboard-interactive" SSH authentication method.

Methods
Included Modules
Constants
InfoRequest = Struct.new( :name, :instruction, :password, :prompts )
  Represents an information request from the server
Prompt = Struct.new( :prompt, :echo )
  Represents a single prompt in an InfoRequest.
USERAUTH_INFO_REQUEST = 60
USERAUTH_INFO_RESPONSE = 61
Attributes
[W] messenger The messenger to use when communicating.
Public Class methods
new( buffers, callback )

Create a new Password authenticator. It will use the given buffers factory to create new buffer instances. The callback should be a proc object to use to specialize the behavior of this authentication method.

    # File lib/net/ssh/userauth/methods/keyboard-interactive.rb, line 45
45:           def initialize( buffers, callback )
46:             @buffers = buffers
47:             @callback = callback
48:           end
Public Instance methods
authenticate( next_service, username, data={} )

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/keyboard-interactive.rb, line 53
53:           def authenticate( next_service, username, data={} )
54:             password = data[:password]
55: 
56:             msg = @buffers.writer
57:             msg.write_byte USERAUTH_REQUEST
58:             msg.write_string username
59:             msg.write_string next_service
60:             msg.write_string "keyboard-interactive"
61:             msg.write_string ""
62:             msg.write_string ""
63:             @messenger.send_message msg
64: 
65:             loop do
66:               message = @messenger.wait_for_message
67: 
68:               case message.message_type
69:                 when USERAUTH_SUCCESS
70:                   return true
71:                 when USERAUTH_FAILURE
72:                   return false
73:                 when USERAUTH_INFO_REQUEST
74:                   name = message.buffer.read_string
75:                   instruction = message.buffer.read_string
76:                   req = InfoRequest.new( name, instruction, password, [] )
77:                   password = nil # only use the given password once
78: 
79:                   lang_tag = message.buffer.read_string
80:                   message.buffer.read_long.times do
81:                     prompt = message.buffer.read_string
82:                     echo = message.buffer.read_bool
83:                     req.prompts << Prompt.new( prompt, echo )
84:                   end
85: 
86:                   responses = @callback.call( req )
87:                   msg = @buffers.writer
88:                   msg.write_byte USERAUTH_INFO_RESPONSE
89:                   msg.write_long responses.length
90:                   msg.write_string *responses
91:                   @messenger.send_message msg
92:                 else
93:                   raise Net::SSH::Exception,
94:                     "unexpected reply in keyboard interactive: " +
95:                       message.inspect
96:               end
97:             end
98:           end