Skip to content

Commit 2479a6e

Browse files
committed
Handle simple non password requests in USER AUTH INFO REQUEST
1 parent f54a227 commit 2479a6e

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

lib/net/ssh/authentication/methods/keyboard_interactive.rb

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,21 @@ def authenticate(next_service, username, password = nil)
5050
message.read_long.times do
5151
text = message.read_string
5252
echo = message.read_bool
53-
password_to_send = password || (prompter && prompter.ask(text, echo))
54-
responses << password_to_send
55-
end
5653

57-
# if the password failed the first time around, don't try
58-
# and use it on subsequent requests.
59-
password = nil
54+
# if request is for password, handle as normal
55+
# otherwise grab yes keyword from the prompt and enter it.
56+
if text.match(/[Pp]assword/)
57+
password_to_send = password || (prompter && prompter.ask(text, echo))
58+
59+
# if the password failed the first time around, don't try
60+
# and use it on subsequent requests. Moved into the if/else
61+
password = nil
62+
elsif response = text.match(/(yes|y)\//i)
63+
debug { " response: #{response}"}
64+
password_to_send = response[1]
65+
end
66+
responses << password_to_send
67+
end
6068

6169
msg = Buffer.from(:byte, USERAUTH_INFO_RESPONSE, :long, responses.length, :string, responses)
6270
send_message(msg)

0 commit comments

Comments
 (0)