How can I re-download the pem file in AWS EC2?

I made a key pair pem file called "test.pem", and I downloaded to my PC.

I made a new instance with this pem file.

Now I am in a different pc, and I don't have this pem file in my local, and my previous pc is in the middle of the sea (shipping).

How can I re-download the "test.pem" file again?


Solution 1:

No, you cannot download .pem file again. You can download the .pem file ONLY once and that is when you create a new key-pair.

Solution 2:

You can not download such security key files more than once. You can reuse them for multiple instances.

Best you can do is to download it and also store it at S3, of course in a private access bucket.

Solution 3:

You can recover you machine even if you lost pem file, there is a way:

1.create new instance with same region and VPC.

2.stop old machine (do not terminate).

3.Goto EBS , detach the root volume of old machine.

4.Now time to attach new volume to new instance(/dev/sdf).but this newly attached volume will be secondary for new instance because it will have its default root volume.

5.Login to new machine and follow below steps: # mount /dev/xvdf1 /mnt # cp /root/.ssh/authorized_keys /mnt/root/.ssh/ # umount /mnt

  1. detach secondary volume from new instance.

  2. Attach this volume back to old instance.

  3. login back to old machine using pem file you got at time of creation of new instance for recovery.