Randomly generated SSH key pairs left behind on AWS EC2 after Packer is done

170 views
Skip to first unread message

Amedee Van Gasse

unread,
Apr 15, 2021, 8:07:23 AM4/15/21
to Packer
I'm using Packer to create AMIs on AWS EC2.
I understand that Packer uses a randomly generated SSH key pair to connect to an EC2 instance that will be the AMI.

Now I have seen in the AWS console, in Key pairs, that there are dozens of leftover key pairs, all named packer_<some-long-hexadecimal-id>.

I know that I can manually delete these keys, but is there a way to tell Packer to delete the key pair on AWS when it is done?

Amedee Van Gasse

unread,
Apr 15, 2021, 8:09:01 AM4/15/21
to Packer
Packer version: 1.6.6
My operating system: Ubuntu

Amedee Van Gasse

unread,
Apr 16, 2021, 5:38:11 AM4/16/21
to Packer
Might be left behind after Packer failed due to other reasons and didn't clean up.
Was answered on Stack Overflow:
Reply all
Reply to author
Forward
0 new messages