Class: Net::SSH::Authentication::Methods::Publickey
- Defined in:
- lib/net/ssh/authentication/methods/publickey.rb
Overview
Implements the "publickey" SSH authentication method.
Constant Summary collapse
- RSA_CERT =
"[email protected]".freeze
- RSA_SIGNATURE_ALGORITHMS =
Key algorithms usable with each RSA key type, mapped to the signature algorithm they imply.
{ "ssh-rsa" => { "rsa-sha2-512" => "rsa-sha2-512", "rsa-sha2-256" => "rsa-sha2-256", "ssh-rsa" => "ssh-rsa" }.freeze, RSA_CERT => { "[email protected]" => "rsa-sha2-512", "[email protected]" => "rsa-sha2-256", RSA_CERT => "ssh-rsa" }.freeze }.freeze
- SIGTYPE_BUG =
Servers that OpenSSH flags with SSH_BUG_SIGTYPE (compat.c): no RSA/SHA-2 certificate signatures.
/\A(OpenSSH_[2-5]|OpenSSH_6\.[56]|OpenSSH_7\.[0-7]|Sun_SSH_1\.0)/.freeze
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
Instance Method Summary collapse
-
#authenticate(next_service, username, password = nil) ⇒ Object
Attempts to perform public-key authentication for the given username, trying each identity known to the key manager.
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, username, password = nil) ⇒ Object
Attempts to perform public-key authentication for the given
username, trying each identity known to the key manager. If any of
them succeed, returns true, otherwise returns false. This
requires the presence of a key manager.
35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/net/ssh/authentication/methods/publickey.rb', line 35 def authenticate(next_service, username, password = nil) return false unless key_manager debug { "pubkey_algorithms: #{pubkey_algorithms.join(', ')}" } key_manager.each_identity do |identity| return true if authenticate_with(identity, next_service, username) end return false end |