Class: Metasploit::Credential::SSHKey
- Defined in:
- app/models/metasploit/credential/ssh_key.rb
Overview
A private SSH key file.
Instance Attribute Summary collapse
-
#data ⇒ String
A private SSH key file’s content including the ‘—–BEGIN <type> PRIVATE KEY—–` header and `—–END <type> PRIVATE KEY—–` footer with everything in between.
Attributes inherited from Private
#cores, #created_at, #id, #type, #updated_at
Instance Method Summary collapse
-
#encrypted? ⇒ false, true
Whether the key data in #data is encrypted.
-
#private? ⇒ false, true
Whether the key data in #data is a private key.
-
#to_s ⇒ String
The key data‘s fingerprint, suitable for displaying to the user.
Instance Attribute Details
#data ⇒ String
A private SSH key file’s content including the ‘—–BEGIN <type> PRIVATE KEY—–` header and `—–END <type> PRIVATE KEY—–` footer with everything in between.
|
# File 'app/models/metasploit/credential/ssh_key.rb', line 9
|
Instance Method Details
#encrypted? ⇒ false, true
Whether the key data in #data is encrypted. Encrypted keys cannot be saved and should be decrypted before saving in a Metasploit::Credential::SSHKey.
44 45 46 47 48 49 50 51 |
# File 'app/models/metasploit/credential/ssh_key.rb', line 44 def encrypted? if data # see https://github.com/net-ssh/net-ssh/blob/1b5db680fee66e1d846d0396eb1a68d3fabdc3de/lib/net/ssh/key_factory.rb#L72 data.match(/ENCRYPTED/) else false end end |
#private? ⇒ false, true
Whether the key data in #data is a private key. Only private keys are supported as public keys cannot be used as Public#data.
58 59 60 61 62 63 64 65 |
# File 'app/models/metasploit/credential/ssh_key.rb', line 58 def private? if data # @see https://github.com/net-ssh/net-ssh/blob/1b5db680fee66e1d846d0396eb1a68d3fabdc3de/lib/net/ssh/key_factory.rb#L56-L69 data.match(/-----BEGIN (.+) PRIVATE KEY-----/) else false end end |
#to_s ⇒ String
The key data‘s fingerprint, suitable for displaying to the user.
71 72 73 |
# File 'app/models/metasploit/credential/ssh_key.rb', line 71 def to_s data ? openssl_pkey_pkey.fingerprint : '' end |