Module: CemAcpt::Utils::SSH::Ephemeral
- Defined in:
- lib/cem_acpt/utils/ssh.rb
Overview
Ephemeral SSH key generation and cleanup
Constant Summary collapse
- PRIV_KEY =
'acpt_test_key'
- CREATE_OPTS =
{ type: 'ed25519', bits: '4096', rounds: '100', comment: 'cem_acpt-ephemeral', password: '', known_hosts: 'acpt_known_hosts', overwrite_known_hosts: true, }.freeze
Class Attribute Summary collapse
-
.ephemeral_keydir ⇒ Object
Returns the value of attribute ephemeral_keydir.
Class Method Summary collapse
Class Attribute Details
.ephemeral_keydir ⇒ Object
Returns the value of attribute ephemeral_keydir.
157 158 159 |
# File 'lib/cem_acpt/utils/ssh.rb', line 157 def ephemeral_keydir @ephemeral_keydir end |
Class Method Details
.clean ⇒ Object
168 169 170 171 172 173 174 175 176 177 178 179 180 |
# File 'lib/cem_acpt/utils/ssh.rb', line 168 def self.clean return if ENV['CEM_ACPT_SSH_PRI_KEY'] [@priv_key, @pub_key, @known_hosts].each_with_object([]) do |f, arr| next unless f path = CemAcpt::Utils::SSH.file_path(f, keydir: ephemeral_keydir) if ::File.exist?(path) ::File.delete(path) arr << path end end end |
.create(keydir: CemAcpt::Utils::SSH.default_keydir) ⇒ Object
160 161 162 163 164 165 166 |
# File 'lib/cem_acpt/utils/ssh.rb', line 160 def self.create(keydir: CemAcpt::Utils::SSH.default_keydir) return [false, false, false] if ENV['CEM_ACPT_SSH_PRI_KEY'] # Don't create ephemeral keys if this is set self.ephemeral_keydir = keydir @priv_key, @pub_key, @known_hosts = CemAcpt::Utils::SSH.create(PRIV_KEY, keydir: ephemeral_keydir, **CREATE_OPTS) [@priv_key, @pub_key, @known_hosts] end |