Class: Net::SSH::Authentication::Methods::None

Inherits:
Abstract
  • Object
show all
Defined in:
lib/net/ssh/authentication/methods/none.rb

Overview

Implements the “none” SSH authentication method.

Constant Summary

Constants included from Constants

Constants::USERAUTH_BANNER, Constants::USERAUTH_FAILURE, Constants::USERAUTH_METHOD_RANGE, Constants::USERAUTH_PASSWD_CHANGEREQ, Constants::USERAUTH_PK_OK, Constants::USERAUTH_REQUEST, Constants::USERAUTH_SUCCESS

Instance Attribute Summary

Attributes inherited from Abstract

#key_manager, #pubkey_algorithms, #session

Attributes included from Loggable

#logger

Instance Method Summary collapse

Methods inherited from Abstract

#initialize, #send_message, #session_id, #userauth_request

Methods included from Loggable

#debug, #error, #fatal, #info, #lwarn

Constructor Details

This class inherits a constructor from Net::SSH::Authentication::Methods::Abstract

Instance Method Details

#authenticate(next_service, user = "", password = "") ⇒ Object

Attempt to authenticate as “none”



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/net/ssh/authentication/methods/none.rb', line 11

def authenticate(next_service, user = "", password = "")
  send_message(userauth_request(user, next_service, "none"))
  message = session.next_message

  case message.type
  when USERAUTH_SUCCESS
    debug { "none succeeded" }
    return true
  when USERAUTH_FAILURE
    debug { "none failed" }

    raise Net::SSH::Authentication::DisallowedMethod unless
      message[:authentications].split(/,/).include? 'none'

    return false
  else
    raise Net::SSH::Exception, "unexpected reply to USERAUTH_REQUEST: #{message.type} (#{message.inspect})"
  end
end