- Newest
- Most votes
- Most comments
In this case there are few ways to set ways to recover password:
- If you SSM agent is installed then you can login to the server using Systems Manager and you can give sudo access for that user from there.
There is another way but downtime will be needed.
-
In other way you can use helper instance in same AZ. You need to stop the problematic server then detach the root volume and attach it to helper instance.
-
Then mount it.
-
Then make entry for that user in sudoers file to allow him sudo access.
For mounting reference:- https://repost.aws/knowledge-center/ec2-linux-emergency-mode
It is not even possible to connect with SSM. If that is the case, the second method of Jahangeer Alam is good.
Another way is to get an AMI and set up a new instance. This also has the disadvantages of slight downtime and changing the public IP address, but you can set your private key to ec2-user
when you create the instance.
The ec2-user
is generally allowed to sudo
without a password.
If you have access to the AWS console with root credentials, the easiest way to update your EC2 user account password is by following these steps:
-
Log in to the AWS Management Console.
-
Navigate to the EC2 dashboard.
-
Select the EC2 instance for which you want to update the password.
-
Click on "Actions" and then select "Instance Settings" > "Get System Log".
-
Look for the log entry that includes "Resetting password for user <your_username>". This entry contains the temporary password generated for your user.
-
Copy the temporary password.
-
SSH into the EC2 instance using your SSH key.
-
Once logged in, use the temporary password to set a new password for your user account using the command:
sudo passwd <your_username>
-
Follow the prompts to set a new password.
After setting the new password, you should be able to use sudo with your updated credentials.
Thanks for the suggestion, however, there are no such entries in the system log.
Relevant content
- asked 2 years ago
- AWS OFFICIALUpdated 23 days ago
- AWS OFFICIALUpdated a year ago
- AWS OFFICIALUpdated a year ago
Depending on the OS configuration, you may be able to switch to root with
su -
without a password, if your user is a member of a suitable group (e.g. wheel)Thanks, @James_S - unfortunately, it prompts me for the password