Class: Orthrus::SSH::Key

Inherits:
Object
  • Object
show all
Defined in:
lib/orthrus/ssh/key.rb

Direct Known Subclasses

PrivateKey, PublicKey

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(k, digest) ⇒ Key

Returns a new instance of Key.



3
4
5
6
7
# File 'lib/orthrus/ssh/key.rb', line 3

def initialize(k, digest)
  @key = k
  @digest = digest
  @comment = nil
end

Instance Attribute Details

#commentObject

Returns the value of attribute comment.



10
11
12
# File 'lib/orthrus/ssh/key.rb', line 10

def comment
  @comment
end

#keyObject (readonly)

Returns the value of attribute key.



9
10
11
# File 'lib/orthrus/ssh/key.rb', line 9

def key
  @key
end

Instance Method Details

#dsa?Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/orthrus/ssh/key.rb', line 16

def dsa?
  @key.kind_of? OpenSSL::PKey::DSA
end

#fingerprintObject



20
21
22
23
# File 'lib/orthrus/ssh/key.rb', line 20

def fingerprint
  blob = public_identity(false)
  OpenSSL::Digest::MD5.hexdigest(blob).scan(/../).join(":")
end

#inspectObject



25
26
27
# File 'lib/orthrus/ssh/key.rb', line 25

def inspect
  "#<#{self.class} #{fingerprint}>"
end

#rsa?Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/orthrus/ssh/key.rb', line 12

def rsa?
  @key.kind_of? OpenSSL::PKey::RSA
end