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:
- Make an AMI (Amazon Machine Instance) of your EC2 instance
- Create another EC2 instance with that AMI, specifying a new key pair, and then
- Swap in that EC2 for the old one, moving any Elastic IPs or DNS entries over to the new EC2 instance
- Verify that everything is working as before, and that you can now SSH into your instance
- Stop and terminate your old instance
- And this time save your keys in a safe place!
Still unsure? Contact us and we can do the work for you.