class Net::SSH::Authentication::Session

def next_message

valid during user authentication.
packets, and will raise an error if any packet is received that is not
Blocks until a packet is received. It silently handles USERAUTH_BANNER
def next_message
  loop do
    packet = transport.next_message
    case packet.type
    when USERAUTH_BANNER
      info { packet[:message] }
    # TODO add a hook for people to retrieve the banner when it is sent
    when USERAUTH_FAILURE
      @allowed_auth_methods = packet[:authentications].split(/,/)
      debug { "allowed methods: #{packet[:authentications]}" }
      return packet
    when USERAUTH_METHOD_RANGE, SERVICE_ACCEPT
      return packet
    when USERAUTH_SUCCESS
      transport.hint :authenticated
      return packet
    else
      raise Net::SSH::Exception, "unexpected message #{packet.type} (#{packet})"
    end
  end
end