Implements the “keyboard-interactive” SSH authentication method.
Attempt to authenticate the given user for the given service.
# File lib/net/ssh/authentication/methods/keyboard_interactive.rb, line 17 17: def authenticate(next_service, username, password=nil) 18: debug { "trying keyboard-interactive" } 19: send_message(userauth_request(username, next_service, "keyboard-interactive", "", "")) 20: 21: loop do 22: message = session.next_message 23: 24: case message.type 25: when USERAUTH_SUCCESS 26: debug { "keyboard-interactive succeeded" } 27: return true 28: when USERAUTH_FAILURE 29: debug { "keyboard-interactive failed" } 30: 31: raise Net::SSH::Authentication::DisallowedMethod unless 32: message[:authentications].split(/,/).include? 'keyboard-interactive' 33: 34: return false 35: when USERAUTH_INFO_REQUEST 36: name = message.read_string 37: instruction = message.read_string 38: debug { "keyboard-interactive info request" } 39: 40: unless password 41: puts(name) unless name.empty? 42: puts(instruction) unless instruction.empty? 43: end 44: 45: lang_tag = message.read_string 46: responses =[] 47: 48: message.read_long.times do 49: text = message.read_string 50: echo = message.read_bool 51: responses << (password || prompt(text, echo)) 52: end 53: 54: # if the password failed the first time around, don't try 55: # and use it on subsequent requests. 56: password = nil 57: 58: msg = Buffer.from(:byte, USERAUTH_INFO_RESPONSE, :long, responses.length, :string, responses) 59: send_message(msg) 60: else 61: raise Net::SSH::Exception, "unexpected reply in keyboard interactive: #{message.type} (#{message.inspect})" 62: end 63: end 64: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.