Skip to content

Commit 2cdf999

Browse files
authored
Add support for specifying the SSH key type to be automatically generated (#583)
AL2022+ is based on Fedora 35 which only supports ed25519 out of the box
1 parent c474342 commit 2cdf999

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

lib/kitchen/driver/ec2.rb

+2-1
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ class Ec2 < Kitchen::Driver::Base
8080
default_config :aws_secret_access_key, nil
8181
default_config :aws_session_token, nil
8282
default_config :aws_ssh_key_id, ENV["AWS_SSH_KEY_ID"]
83+
default_config :aws_ssh_key_type, "rsa"
8384
default_config :image_id, &:default_ami
8485
default_config :image_search, nil
8586
default_config :username, nil
@@ -854,7 +855,7 @@ def create_key(state)
854855
# to rapidly exhaust local entropy by creating a lot of keys. So this is
855856
# probably fine. If you want very high security, probably don't use this
856857
# feature anyway.
857-
resp = ec2.client.create_key_pair(key_name: "kitchen-#{name_parts.join("-")}")
858+
resp = ec2.client.create_key_pair(key_name: "kitchen-#{name_parts.join("-")}", key_type: config[:aws_ssh_key_type])
858859
state[:auto_key_id] = resp.key_name
859860
info("Created automatic key pair #{state[:auto_key_id]}")
860861
# Write the key out with safe permissions

spec/kitchen/driver/ec2_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@
422422
config.delete(:aws_ssh_key_id)
423423
allow(instance).to receive(:name).and_return("instance_name")
424424

425-
expect(actual_client).to receive(:create_key_pair).with(key_name: /kitchen-/).and_return(double(key_name: "expected-key-name", key_material: "RSA PRIVATE KEY"))
425+
expect(actual_client).to receive(:create_key_pair).with(key_name: /kitchen-/, key_type: "rsa").and_return(double(key_name: "expected-key-name", key_material: "RSA PRIVATE KEY"))
426426
fake_file = double
427427
allow(File).to receive(:open).and_call_original
428428
expect(File).to receive(:open).with("/kitchen/.kitchen/instance_name.pem", kind_of(Numeric), kind_of(Numeric)).and_yield(fake_file)

0 commit comments

Comments
 (0)