Lost Key Pair of AWS EC2 Instance? Follow These Steps to Connect to The Server
Lost Key Pair of AWS EC2 Instance


The Amazon EC2 instances require a key pair to connect to the instance using SSH. Without this key pair, we cannot do SSH to the instance. 

You might lose the key of the instance, or maybe someone deleted the key by mistake. 

Losing a key file doesn’t mean you lost your data; it is just that you will not be able to SSH into the instance.

To resolve this situation, you can create the AMI of the current instance and launch this AMI as an instance with a new key pair.

Steps to Follow to Connect to the Server If you Lost AWS EC2 Instance Key Pair

Follow the steps mentioned to create an AMI and launch the instance with the new key pair:

  • Log into your AWS management console and navigate to EC2.
  • Select the instance and click on Actions drop-down menu, hover on the image, and click Create Image.
  • Create Image window appears. Fill the details Image name, Image description, and click on Create Image.
    Note: There is a checkbox No reboot; by default, the checkbox is not selected, which means when the image is taken, the Instance will not be restarted. And if this checkbox is selected, the Instance will be restarted. 
a screenshot of a cell phone
  • The time taken to create an image depends on the instance type and the size of the EBS volume of the instance. 
  • Click on Images drop-down and select AMIs to view the status of your image.
  • Once the AMI status is updated to Available status, you can Launch an EC2 instance using this image.
a screenshot of a social media post
  • The launch wizard appears. The same steps are to be followed as we do while launching an EC2 instances. Create a new key pair while launching the Instance.
a screenshot of a social media post


The AWS EC2 instance now uses the new key file.

Related Posts