- Newest
- Most votes
- Most comments
Hi, here is the guidance to recover access to your EC2 instance: https://repost.aws/knowledge-center/user-data-replace-key-pair-ec2
Fingers crossed! Didier
The edit user data did not work for me. I was gonna try the AWSSupport-ResetAccess but I'm afraid it affects my data on the instance
Hello,
This may help if it's EBS backed https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/TroubleshootingInstancesConnecting.html#replacing-lost-key-pair
Another option,
If it's an AMI, it may have the option for Session Manger as well. As long as it has the correct SSM role, you may be able to log into the server and update the public key there. I've added the steps below, if you are able to log into the server.
- Create a new key pair using the Amazon EC2 console or a third-party tool.
- Retrieve the public key from your new key pair. For more information, see Retrieve the public key material.
- Connect to your instance using SSM.
- Using a text editor of your choice, open the .ssh/authorized_keys file on the instance. Paste the public key information from your new key pair underneath the existing public key information. Save the file.
- Disconnect from your instance, and test that you can connect to your instance using the new private key file.
(https://docs.aws.amazon.com/systems-manager/latest/userguide/session-manager.html)
Relevant content
- asked 9 months ago
- asked 5 years ago
- Accepted Answerasked 2 years ago
- asked 2 years ago
- AWS OFFICIALUpdated a month ago
- AWS OFFICIALUpdated 7 months ago
- AWS OFFICIALUpdated 2 months ago
- AWS OFFICIALUpdated 2 months ago