How can I manually reset the root password on my Linux virtual server in recovery?
- Reboot in recovery.
- Log in via recovery with user/password which is
root/recovery
or root/defaultrootpassword
. If recovery does not work, try the default root password listed in the properties of the virtual server. Check for the disk that has the same size as the one which the virtual server has. For example, 50 GB. If there is 49.x GB, this is the one that is needed. Usually, it is /dev/vda
or /dev/xvda
(it depends on the distribution). Additionally, it shows the partitions. In most cases, the partition is /dev/vda1
.
Mount the disk. For example, you can create a directory under /mnt
for this:
and then mount it:
mount /dev/vda1 /mnt/vda1
CODE
To make the environment usable, bind /proc
, bind /sys
, and bind /dev
to this environment:
mount --bind /proc /mnt/vda1/proc
mount --bind /sys /mnt/vda1/sys
mount --bind /dev /mnt/vda1/dev
CODE
Change the root to this environment:
If you check your pwd
(present working directory), you will get /
, because you are at the root of this environment now. Double check if you are still root with whoami
and run passwd
. Update the password for the root user. The current password is not required.
Use exit
to leave the environment and go back to the recovery image. Unmount binds and disk:
cd /
umount /mnt/vda1/proc
umount /mnt/vda1/dev
umount /mnt/vda1/sys
umount /mnt/vda1
CODE
The command cd
is a reminder to make sure you are not in the directory which is unmounting.
- Restart the server.