Class Net::SSH::UserAuth::Methods::HostBased
In: lib/net/ssh/userauth/methods/hostbased.rb
Parent: Object

Implements the host-based SSH authentication method.

Methods

Included Modules

Net::SSH::UserAuth::Constants

Attributes

hostname  [W]  The hostname to report to the server.
messenger  [W]  The messenger to use to send and receive messages.
session_id  [W]  The session-id of the current SSH session.

Public Class methods

Create a new

[Source]

    # File lib/net/ssh/userauth/methods/hostbased.rb, line 39
39:           def initialize( buffers )
40:             @buffers = buffers
41:           end

Public Instance methods

Attempts to perform host-based authorization of the user. The data hash must contain a :key_manager key or the call will fail.

[Source]

    # File lib/net/ssh/userauth/methods/hostbased.rb, line 46
46:           def authenticate( next_service, username, data={} )
47:             key_manager = data[:key_manager] or return false
48: 
49:             key_manager.host_identities.each do |identity|
50:               return true if authenticate_with( identity, next_service,
51:                 username, key_manager )
52:             end
53: 
54:             return false
55: 
56:           ensure
57:             key_manager.finish if key_manager
58:           end

Build the "core" hostbased request string.

[Source]

     # File lib/net/ssh/userauth/methods/hostbased.rb, line 95
 95:           def build_request( identity, next_service, username, hostname,
 96:                client_username )
 97:           # begin
 98:             buf = @buffers.writer
 99:             buf.write_byte USERAUTH_REQUEST
100:             buf.write_string username
101:             buf.write_string next_service
102:             buf.write_string "hostbased"
103: 
104:             buf.write_string identity.ssh_type
105:             blob = @buffers.writer
106:             blob.write_key identity
107:             buf.write_string blob.to_s
108: 
109:             buf.write_string hostname
110:             buf.write_string client_username
111:             return buf.to_s
112:           end

[Validate]