Okay, so say you lose your Amazon cloud server’s key pair. uh oh, yes, you are in trouble, but not to worry to much, there is a solution. The solution is pretty complex if you try to learn it from Amazon docs, so here is an easy explanation that worked for me.
- know the instance name
- write down the availability zone:
- Write down the instance id
High level steps:
Follow these high level steps if you know your way around Amazon’s management console fairly well, otherwise, read on for more specific instructions for replacing an Amazon EC2 instance’s key pair and regain access to your server.
- Shut down instance.
- Make a new AMI from the instance.
- Launch new instance using the AMI you created.
- Create and download a new key pair.
- Start the new instance and check that the key pair works then delete the old instance if you wish.
- Go to aws.amazon.com and login to your account. Select EC2/instances and place a check-mark beside the running instance you need a new key pair for and then select “stop” from the actions drop down. Finally click yes to stop the instance.
- With the same instance still checked, select “Create Image” from the “Actions” drop down. Give the image a name and a description and leave rest of defaults for most cases, then click “yes create”. Take note of the id that looks similar to ami-5d623734 in the next window.
- Click on “AMIs” in the left nav and click “Launch” to launch a new Instance with the AMI”. Click to continue. Make selections similar to your previous instance you are replacing the key pair for. Be sure to select the same availability zone.
- When you get to the third step of creating a new instance, where it says create a key pair, be sure you select “Create a new key pair” and create and download the file. Also be sure to select the same security group you had on the original server. When you are done creating the new instance, write down the instance id like: i-f9ead583 or i-11438868
- Wait for the instance to be created, it can take a few minutes. Go back to your Instances page and place a check beside the newly created Instance. Then you will see it’s information pop up at the bottom of the page. copy the URL that looks like ec2-50-16-136-250.compute-1.amazonaws.com. You can get the IP from that URL by taking the numbers after the ec2- so in my case, the ip was 184.108.40.206 as you can see those numbers in the above URL.
Now that you have your new server, if you need help connecting to it, follow my next tutorial on how to connect to an Amazon ec2 instance and convert a .pem to a .ppk file here:
then after that, follow the link at the bottom of that tutorial to learn now to gain FTP access to your Amazon ec2 web server.