Class: Net::SSH::KeyFactory

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

get load_data_private_key load_data_public_key load_private_key load_public_key

### 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

get(name)

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

load_data_private_key(data, passphrase=nil, filename="")

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.

load_data_public_key(data, filename="")

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.

load_private_key(filename, passphrase=nil)

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.

load_public_key(filename)

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]