I see this question quite often in different forum. People may not be able to log in to their instance because of a number of reasons:
- You just launched and an instance, and your instance is not ready yet.
- Your instance is attached to a security group that doesn’t have ssh (port 22)
- You lost password to your instance
- You lost your private key
And the list goes on. There are different solution for different problems. As for example you need to be little patient for the 1st cause in the list :). In this blog, I will be tackling the last two cause that I listed above.
Here are the steps that I would follow to recover my instance from the situation that you have either lost or broke your authentication mechanism:
1) Create an image from the instance.
- Go to the EC2 console by following the link https://console.aws.amazon.com/ec2/.
- Open the list of instance, and select the instance you are interested in recovering.
- Create image of the instance by clicking ‘Actions->Create Image’. Follow the instruction to create an image. Image name is the only mandatory field. You may leave everything else as default.
2) Wait till your image is created and available to use.
It takes a while to create an AMI. You may want to grab a cup of coffee or tea and come back to check the status. In the EC2 page, you will find ‘AMIs’ under the ‘Image’ on the left panel. Select the AMIs to check the status. Once you see the status turning from ‘Pending’ to Available, you know your image is ready to use.
3) Create a new instance from your new image.
There are multiple ways to create a new instance from your image. The easiest is to launch an image from the AMIs page itself.
- Select the ‘Image’ you just created.
- Click the ‘Launch’ button on the left top of the page and follow the instruction to create an instance.
- If you have lost your key pair, create a new key pair. This will be the last step in the whole process.
Please do not hesitate to contact me if you need any help. I’ll be happy to help you. Just drop me a note.