How to reset the Forgotten root password in AWS-EC2 Instance
Tags: aws, password, awsec2, tutorial
Published: 2022-01-27 06:56:03

It is often found challenging or sometimes difficult to reset the forgotten root password in the AWS system. Administrators, and analysts have their task cut out already with deployments or overseeing smooth running of IT systems. The password reset methods in the AWS system is bit difficult and professionals find it time consuming to address this challenge.

Here are the steps to resolve it:

- Power Off the instance (Example project Server)

- Note the Ebs Volume info (dev/sda1), and detach the volume from server.

- Create a new instance (Dummy Instance) with minimal configuration, it must be a same region as example project Server.

- Attach the Example project Root volume to New instance (Dummy Instance),

- Login to Dummy Instance,

- Check the volumes using following command

💻 lsblk


- Mount the Example project root volume to the Dummy Instance,

💻 Create directory : mkdir /mnt
💻 mount the volume : mount /dev/sda /mnt 


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/n3b1uq01px2g6kxds49k.png) 

- Create the new user in dummy instance and set the password.

💻 Create a new user : useradd Sennovate
💻 Set Password for the new user: passwd Sennovate 🚨(Note down the Password) 

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1x7muzhswwrxxjthqftl.png) 

- Get the sennovate user encryption password from  /etc/shadows.

(Like: $1$iJjm1IwS$0HA2.5f8d6Cpq6XQTv5KU.:17780:0:99999:7:::)

💻 cat /etc/shadow


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/axjxi1md2x4hv0u7w0cs.png)

- Go to the mount location and open the shadows file,

💻  cd ~

💻 cd /etc/

💻 sudo vi shadow

then change the encryption value to Example project user.($1$iJjm1IwS$0HA2.5f8d6Cpq6XQTv5KU.:17780:0:99999:7:::)


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/o8qrcm3li6z1ip8vy9v7.png)

- After changing the value just un-mount the volume from Dummy Instance.

💻 To un-mount: un-mount /dev/sda 


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/evevz1tjbt62czxaxl2o.png) 

- Detach the volume from dummy server and attach to Example project server

- Now you can login to the instance as usual.

No worries if you lost the root password. By implementing the above procedure, it’s just a walk in the park where you can easily reset a lost or forgotten root password in AWS EC instance.

 
Having any doubts or want to have a call with us to know more about AWS and IAM?
Contact us right now by [clicking here](https://sennovate.com/contact-sennovate/) Sennovate’s AWS Experts will explain everything
on call in detail.
You can also write a mail to us at hello@sennovate.com or call us on +1 (925) 918-6618.
 

## About Sennovate

Sennovate delivers custom identity and access management solutions to businesses around the world. With global partners and a library of 1000+ integrations, we implement world-class cybersecurity solutions that save your company time and money. We offer a seamless experience with integration across all cloud applications, and a single price for product, implementation, and support. Have questions? The consultation is always free. Email hello@sennovate.com or call us at: +1 (925) 918-6618.