I lost my Access Key Pair to an EC2 server, how do I retrieve it?
Is there a way to generate a new Key Pair and add it to an existing instance?
I lost my Access Key Pair to an EC2 server, how do I retrieve it?
Is there a way to generate a new Key Pair and add it to an existing instance?
If the user loses the Key Pair, and has not previously prepared any other form of access to your instance, there is really nothing to do - Access is lost ! (except in special cases, see below)
This is because AWS has no way to access your instance - you were the only one who had the key. The key is installed on the instance itself during the first boot process - AWS has no way to connect to your instance and change the key for you. In subsequent boots, this process does not run, so it's no use generating a new key from the console, with a new name or even a name, or anything like that.
Depending on your specific circumstances, you can do a very manual and laborious process to gain access back to your instance. This process only applies to instances that use EBS as the root device, and in addition all content written to instance store will be lost.
From the AWS documentation:
Amazon EC2 does not keep a copy of your private key; therefore, if you lose your private key, there is no way to recover it. If you lose the private key for an instance store-backed instance, you can not access the instance; you should terminate the instance and launch another instance using a new key pair. If you lose the private key for an EBS-backed instance, you can regain access to your instance.
Source and more information about the recovery process: link
Another way to solve this would be:
/dev/sda1
You have the option of either using Volume EBS that was created together with the new instance or reconnecting it to the instance as an extra disk, which could serve as backup for example.
We have 2 possibilities:
All this is in the EC2 Console , Network & Security > Key Pairs .