Class: SSHKey
- Inherits:
-
Object
- Object
- SSHKey
- Defined in:
- lib/sshkey.rb,
lib/sshkey/version.rb
Constant Summary collapse
- VERSION =
"1.1.2"
Instance Attribute Summary collapse
-
#comment ⇒ Object
readonly
Returns the value of attribute comment.
-
#fingerprint ⇒ Object
readonly
Returns the value of attribute fingerprint.
-
#key_object ⇒ Object
readonly
Returns the value of attribute key_object.
-
#rsa_private_key ⇒ Object
readonly
Returns the value of attribute rsa_private_key.
-
#rsa_public_key ⇒ Object
readonly
Returns the value of attribute rsa_public_key.
-
#ssh_public_key ⇒ Object
readonly
Returns the value of attribute ssh_public_key.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(private_key, options = {}) ⇒ SSHKey
constructor
A new instance of SSHKey.
Constructor Details
#initialize(private_key, options = {}) ⇒ SSHKey
Returns a new instance of SSHKey.
13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/sshkey.rb', line 13 def initialize(private_key, = {}) @key_object = OpenSSL::PKey::RSA.new(private_key) @comment = [:comment] || "" @rsa_private_key = @key_object.to_pem @rsa_public_key = @key_object.public_key.to_pem raw_ssh_public_key = ssh_public_key_conversion @ssh_public_key = [ "ssh-rsa", Base64.encode64(raw_ssh_public_key).gsub("\n", ""), @comment, ].join(" ").strip @fingerprint = Digest::MD5.hexdigest(raw_ssh_public_key).gsub(/(.{2})(?=.)/, '\1:\2') end |
Instance Attribute Details
#comment ⇒ Object (readonly)
Returns the value of attribute comment.
11 12 13 |
# File 'lib/sshkey.rb', line 11 def comment @comment end |
#fingerprint ⇒ Object (readonly)
Returns the value of attribute fingerprint.
11 12 13 |
# File 'lib/sshkey.rb', line 11 def fingerprint @fingerprint end |
#key_object ⇒ Object (readonly)
Returns the value of attribute key_object.
11 12 13 |
# File 'lib/sshkey.rb', line 11 def key_object @key_object end |
#rsa_private_key ⇒ Object (readonly)
Returns the value of attribute rsa_private_key.
11 12 13 |
# File 'lib/sshkey.rb', line 11 def rsa_private_key @rsa_private_key end |
#rsa_public_key ⇒ Object (readonly)
Returns the value of attribute rsa_public_key.
11 12 13 |
# File 'lib/sshkey.rb', line 11 def rsa_public_key @rsa_public_key end |
#ssh_public_key ⇒ Object (readonly)
Returns the value of attribute ssh_public_key.
11 12 13 |
# File 'lib/sshkey.rb', line 11 def ssh_public_key @ssh_public_key end |