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
8
# File 'lib/orthrus/ssh/key.rb', line 3

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

Instance Attribute Details

#commentObject

Returns the value of attribute comment.



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

def comment
  @comment
end

#keyObject (readonly)

Returns the value of attribute key.



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

def key
  @key
end

#sourceObject

Returns the value of attribute source.



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

def source
  @source
end

Instance Method Details

#==(o) ⇒ Object



30
31
32
33
# File 'lib/orthrus/ssh/key.rb', line 30

def ==(o)
  return false unless o.kind_of? Orthrus::SSH::Key
  @key.to_pem == o.key.to_pem
end

#dsa?Boolean

Returns:

  • (Boolean)


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

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

#fingerprintObject



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

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

#inspectObject



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

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

#rsa?Boolean

Returns:

  • (Boolean)


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

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