Module: Kitchen::Driver::Oci::Mixin::SshKeys
- Included in:
- Instance
- Defined in:
- lib/kitchen/driver/oci/mixin/ssh_keys.rb
Overview
SSH key generation mixins.
Defined Under Namespace
Instance Method Summary collapse
-
#algorithm ⇒ String
Algorithm used when encoding the private and public keys.
-
#generate_keys ⇒ Object
Generates the public/private key pair in the format specified in the config.
-
#private_key_file ⇒ String
The location of the private ssh key.
-
#public_key_file ⇒ String
The location of the public ssh key.
-
#read_public_key ⇒ String
Read in the public ssh key.
Instance Method Details
#algorithm ⇒ String
Algorithm used when encoding the private and public keys.
60 61 62 |
# File 'lib/kitchen/driver/oci/mixin/ssh_keys.rb', line 60 def algorithm "ssh-#{config[:ssh_keytype]}" end |
#generate_keys ⇒ Object
Generates the public/private key pair in the format specified in the config.
65 66 67 68 69 |
# File 'lib/kitchen/driver/oci/mixin/ssh_keys.rb', line 65 def generate_keys FileUtils.mkdir_p("#{config[:kitchen_root]}/.kitchen/.ssh") extend SshKeys.const_get(config[:ssh_keytype].upcase) generate_key_pair end |
#private_key_file ⇒ String
The location of the private ssh key.
42 43 44 |
# File 'lib/kitchen/driver/oci/mixin/ssh_keys.rb', line 42 def private_key_file public_key_file.gsub(".pub", "") end |
#public_key_file ⇒ String
The location of the public ssh key.
49 50 51 52 53 54 55 |
# File 'lib/kitchen/driver/oci/mixin/ssh_keys.rb', line 49 def public_key_file if config[:ssh_keygen] "#{config[:kitchen_root]}/.kitchen/.ssh/#{config[:instance_name]}_#{config[:ssh_keytype]}.pub" else config[:ssh_keypath] end end |
#read_public_key ⇒ String
Read in the public ssh key.
31 32 33 34 35 36 37 |
# File 'lib/kitchen/driver/oci/mixin/ssh_keys.rb', line 31 def read_public_key if config[:ssh_keygen] logger.info("Generating public/private #{config[:ssh_keytype]} key pair") generate_keys end File.readlines(public_key_file).first.chomp end |