preloader

AWS Quick Tips: Lost Key Pair

AWS Quick Tips: Lost Key Pair
By J. Toman / on 16 Sep, 2019

I lost my key pair to my EC2 instance. How can I retrieve them?

You can’t. Once they’re gone, they’re gone. If you could retrieve them then theoretically some bad guy could retrieve them too. However, the Golden Rule of Cloud Computing is

    Infrastructure is transient, data is forever. 

which means that servers, database instances, gateways come and go. Only the data matters. So what you can do is this:

  1. Make an AMI (Amazon Machine Instance) of your EC2 instance
  2. Create another EC2 instance with that AMI, specifying a new key pair, and then
  3. Swap in that EC2 for the old one, moving any Elastic IPs or DNS entries over to the new EC2 instance
  4. Verify that everything is working as before, and that you can now SSH into your instance
  5. Stop and terminate your old instance
  6. And this time save your keys in a safe place!

Still unsure? Contact us and we can do the work for you.