AWS - How To Access The EC2 Instance Whose Private Key(.pem file) Got Deleted Or Misplaced | Part-2

Опубликовано: 11 Июль 2026
на канале: CloudJourney with Satyajit
224
13

AWS - How To Access The EC2 Instance Whose Private Key(.pem file) Got Deleted Or Misplaced | Part-2

If Accidentally the Private key (.Pem file) deleted then we can follow the below steps to recover it.
1. Attach the root volume to another instance: If both the keys misplaced like the default .pem file and the newly created keys , then we can not access to the EC2 instance. We can achieve it by doing the following steps.

2. Create a new EC2 instance or use an existing instance and that should be in the same availability zone where your inaccessible server is present
3. Stop the inaccessible EC2 instance.
4. Detach the root volume from the inaccessible instance.
5. Attach the detached root volume to the new instance as an additional volume.
6. Mount the volume( Do temporary mount and don’t provide any filesystem, otherwise all the data will be wipe out)from the inaccessible instance to a directory in the new instance.
command: mount -t xfs -o nouuid "disk path" "mount path"
7. Modify the necessary files (e.g., SSH configuration) to regain access.
Once done, unmount the volume, detach it from the new instance, and reattach it to the original instance.
8. Start the original instance and attempt to connect using the modified settings.
I wrote a blog for this and all the steps are written and below is the link of the blogs
Blogs for this:
  / how-to-access-the-ec2-instance-whose-priva...  

#DeletedPEMFileRecovery
#RecoverPEMFile
#LostPEMFileRecovery
#PEMFileRecoveryTips
#aws
#Private key