Class Net::SSH::KeyFactory
In: lib/net/ssh/key_factory.rb
Parent: Object

A factory class for returning new Key classes. It is used for obtaining OpenSSL key instances via their SSH names, and for loading both public and private keys. It used used primarily by Net::SSH itself, internally, and will rarely (if ever) be directly used by consumers of the library.

  klass = Net::SSH::KeyFactory.get("rsa")
  assert klass.is_a?(OpenSSL::PKey::RSA)

  key = Net::SSH::KeyFacory.load_public_key("~/.ssh/id_dsa.pub")

Methods

Included Modules

Prompt

Constants

MAP = { "dh" => OpenSSL::PKey::DH, "rsa" => OpenSSL::PKey::RSA, "dsa" => OpenSSL::PKey::DSA   Specifies the mapping of SSH names to OpenSSL key classes.

Public Class methods

Fetch an OpenSSL key instance by its SSH name. It will be a new, empty key of the given type.

Loads a private key. It will correctly determine whether the file describes an RSA or DSA key, and will load it appropriately. The new key is returned. If the key itself is encrypted (requiring a passphrase to use), the user will be prompted to enter their password unless passphrase works.

Loads a public key. It will correctly determine whether the file describes an RSA or DSA key, and will load it appropriately. The new public key is returned.

Loads a private key from a file. It will correctly determine whether the file describes an RSA or DSA key, and will load it appropriately. The new key is returned. If the key itself is encrypted (requiring a passphrase to use), the user will be prompted to enter their password unless passphrase works.

Loads a public key from a file. It will correctly determine whether the file describes an RSA or DSA key, and will load it appropriately. The new public key is returned.

[Validate]