Class: Mccloud::Util::SSHKey
- Inherits:
-
Object
- Object
- Mccloud::Util::SSHKey
- Defined in:
- lib/mccloud/util/sshkey.rb
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.
19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/mccloud/util/sshkey.rb', line 19 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.strict_encode64(raw_ssh_public_key), @comment].join(" ").strip @ssh_public_key = ["ssh-rsa", [raw_ssh_public_key].pack("m0").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.
17 18 19 |
# File 'lib/mccloud/util/sshkey.rb', line 17 def comment @comment end |
#fingerprint ⇒ Object (readonly)
Returns the value of attribute fingerprint.
17 18 19 |
# File 'lib/mccloud/util/sshkey.rb', line 17 def fingerprint @fingerprint end |
#key_object ⇒ Object (readonly)
Returns the value of attribute key_object.
17 18 19 |
# File 'lib/mccloud/util/sshkey.rb', line 17 def key_object @key_object end |
#rsa_private_key ⇒ Object (readonly)
Returns the value of attribute rsa_private_key.
17 18 19 |
# File 'lib/mccloud/util/sshkey.rb', line 17 def rsa_private_key @rsa_private_key end |
#rsa_public_key ⇒ Object (readonly)
Returns the value of attribute rsa_public_key.
17 18 19 |
# File 'lib/mccloud/util/sshkey.rb', line 17 def rsa_public_key @rsa_public_key end |
#ssh_public_key ⇒ Object (readonly)
Returns the value of attribute ssh_public_key.
17 18 19 |
# File 'lib/mccloud/util/sshkey.rb', line 17 def ssh_public_key @ssh_public_key end |