Class: Facter::Util::Resolvers::SshHelper
- Inherits:
-
Object
- Object
- Facter::Util::Resolvers::SshHelper
- Defined in:
- lib/facter/util/resolvers/ssh_helper.rb
Constant Summary collapse
- SSH_NAME =
{ 'ssh-dss' => 'dsa', 'ecdsa-sha2-nistp256' => 'ecdsa', 'ecdsa-sha2-nistp384' => 'ecdsa', 'ecdsa-sha2-nistp521' => 'ecdsa', 'ssh-ed25519' => 'ed25519', 'ssh-rsa' => 'rsa' }.freeze
- SSH_FINGERPRINT =
{ 'rsa' => 1, 'dsa' => 2, 'ecdsa' => 3, 'ed25519' => 4 }.freeze
Class Method Summary collapse
Class Method Details
.create_ssh(key_type, key) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/facter/util/resolvers/ssh_helper.rb', line 16 def create_ssh(key_type, key) key_name = SSH_NAME[key_type] return unless key_name # decode64 ignores non-base64 characters including newlines decoded_key = Base64.decode64(key) ssh_fp = SSH_FINGERPRINT[key_name] sha1 = "SSHFP #{ssh_fp} 1 #{Digest::SHA1.new.update(decoded_key)}" sha256 = "SSHFP #{ssh_fp} 2 #{Digest::SHA2.new.update(decoded_key)}" fingerprint = Facter::Util::Resolvers::FingerPrint.new(sha1, sha256) Facter::Util::Resolvers::Ssh.new(fingerprint, key_type, key, key_name) end |