class Net::SSH::Authentication::Methods::Abstract

  1. lib/net/ssh/authentication/methods/abstract.rb
Parent: Methods

The base class of all user authentication methods. It provides a few bits of common functionality.

Methods

Public Class

  1. new

Public Instance

  1. key_manager
  2. send_message
  3. session
  4. session_id
  5. userauth_request

Included modules

  1. Constants
  2. Loggable

Attributes

key_manager [R]

The key manager object. Not all authentication methods will require this.

session [R]

The authentication session object

Public Class methods

new (session, options={})

Instantiates a new authentication method.

[show source]
# File lib/net/ssh/authentication/methods/abstract.rb, line 21
def initialize(session, options={})
  @session = session
  @key_manager = options[:key_manager]
  @options = options
  self.logger = session.logger
end

Public Instance methods

send_message (msg)

Sends a message via the underlying transport layer abstraction. This will block until the message is completely sent.

[show source]
# File lib/net/ssh/authentication/methods/abstract.rb, line 36
def send_message(msg)
  session.transport.send_message(msg)
end
session_id ()

Returns the session-id, as generated during the first key exchange of an SSH connection.

[show source]
# File lib/net/ssh/authentication/methods/abstract.rb, line 30
def session_id
  session.transport.algorithms.session_id
end
userauth_request (username, next_service, auth_method, *others)

Creates a new USERAUTH_REQUEST packet. The extra arguments on the end must be either boolean values or strings, and are tacked onto the end of the packet. The new packet is returned, ready for sending.

[show source]
# File lib/net/ssh/authentication/methods/abstract.rb, line 43
def userauth_request(username, next_service, auth_method, *others)
  buffer = Net::SSH::Buffer.from(:byte, USERAUTH_REQUEST,
    :string, username, :string, next_service, :string, auth_method)

  others.each do |value|
    case value
    when true, false then buffer.write_bool(value)
    when String      then buffer.write_string(value)
    else raise ArgumentError, "don't know how to write #{value.inspect}"
    end
  end

  buffer
end