Replace the pem file for an EC2 instance running Windows

0

I'm looking for some guidance on replacing the pem file associated with an EC2 instance running Windows.

The AWS documentation on key pairs for Windows doesn't seem to mention this, and the general advice seems more geared towards Linux.

I have the old pem file and just want to replace it for security reasons. Any help would be appreciated!

Resources I've read through so far are below:
https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-key-pairs.html#replacing-key-pair
https://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/ec2-key-pairs.html

asked 3 years ago2537 views
1 Answer
1

Good day Jamielaird

According to my understanding you are trying to replace a .pem key file that is associated with an existing EC2 instance running Windows for security reasons.

Based on my investigation and replication to your question, these are the steps I followed:
Note: To give the new key pair the same name as the old key pair, you must first delete the old key pair

1.Create a new key pair, and then save the private key file in a safe place. You can create a key pair using the console, the AWS CLI, or AWS Tools for Windows PowerShell.
2. From the Amazon EC2 console, choose Instances from the navigation pane.
3. Select your instance
4. Stop your instance
5. Select your instance. For Actions, choose Image, Create Image. For Image name, enter a name.
6. Create Image, and then choose Close.
7. Launch an AMI - Launch an instance.
8. Complete the wizard. Be sure to select the same Instance type, VPC ID, Subnet ID, Security groups, and IAM role as the instance that you are replacing For Select a key pair, choose the new key pair.
9. Now that the private key file is replaced, you can reset the administrator password.

To reset your administrator password:
Use EC2Config for Windows Server 2012 R2 and earlier. https://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/ResettingAdminPassword_EC2Launch.html

Use EC2Launch for Windows Server 2016 and later https://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/ResettingAdminPassword_EC2Config.html

References
[1] https://aws.amazon.com/premiumsupport/knowledge-center/ec2-windows-replace-lost-key-pair/

Lihle
answered 2 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions