class SSHKey

def initialize(private_key, options = {})


* :directives<~Array> - Options prefixed to the public key
* :passphrase<~String> - If the key is encrypted, supply the passphrase
* :comment<~String> - Comment to use for the public key, defaults to ""
* options<~Hash>
* private_key - Existing RSA or DSA or ECDSA private key
==== Parameters

Create a new SSHKey object
def initialize(private_key, options = {})
  @passphrase = options[:passphrase]
  @comment    = options[:comment] || ""
  self.directives = options[:directives] || []
  begin
    @key_object = OpenSSL::PKey::RSA.new(private_key, passphrase)
    @type = "rsa"
    @typestr = "ssh-rsa"
  rescue OpenSSL::PKey::RSAError
    @type = nil
  end
  return if @type
  begin
    @key_object = OpenSSL::PKey::DSA.new(private_key, passphrase)
    @type = "dsa"
    @typestr = "ssh-dss"
  rescue OpenSSL::PKey::DSAError
    @type = nil
  end
  return if @type
  @key_object = OpenSSL::PKey::EC.new(private_key, passphrase)
  @type = "ecdsa"
  bits = ECDSA_CURVES.invert[@key_object.group.curve_name]
  @typestr = "ecdsa-sha2-nistp#{bits}"
end