To change your root password once you have lost it, you need to reboot your VPS in rescue mode.
In rescue mode, you can reboot your server on an independent configuration. Your disk can then be mounted on an independent partition.
The advantage of this is that you can carry out tests and make configuration changes when it is most convenient for you, and when it will have the least impact on the operations performed by your server.
This also allows you to correct any configuration errors made which prevented you from accessing the server
Note: If you have any services online, rescue mode will interrupt them as the server is being rebooted into the rescue environment
This guide will show you how to reboot in rescue mode.
You must be logged in to your client area.
Once you have logged in to your client area, click Services and select your specific server e.g Cloudpap1
- Scroll down and click the Power button. Select Netboot, choose Rescue from the drop down and then click the Boot Now button. Click yes afterwards.
After clicking yes, your server will be rebooted in rescue mode and you will receive by email a temporary root access password.
After getting the temporary root password, you can now SSH into your server from the command line.
Log in to your server with the correct SSH command and the temporary root password.
$ ssh [email protected]
The authenticity of host '167.114.xx.yy (167.114.xx.yy)' can't be established.
RSA key fingerprint is 02:11:f2:db:ad:42:86:de:f3:10:9a:fa:41:2d:09:77.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '167.114.xx.yy' (RSA) to the list of known hosts.
Step 1 : Identify the mount point
The mount is created automatically on VPS so you just need to identify where your partition is
To do this, you can use two commands, df -h and lsblk:
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 2.9G 1.6G 1.2G 57% /
udev 10M 0 10M 0% /dev
tmpfs 1.6G 8.4M 1.6G 1% /run
tmpfs 3.9G 0 3.9G 0% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup
/dev/sdb1 40G 3.2G 35G 9% /mnt/sdb1
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 3G 0 disk
└─sda1 8:1 0 3G 0 part /
sdb 8:16 0 40G 0 disk
└─sdb1 8:17 0 40G 0 part /mnt/sdb1
From the above, it shows that your partition is mounted on /mnt/sdb1
Step 2: CHROOT Permissions
You now need to edit the root directory, for changes to be applied to your system. You can do this by using the ‘chroot command.
Please enter the following command:
root@rescue-pro:~# chroot /mnt/sdb1
You can check by typing the ls-l command, which will list the content stored in the root directory of your system
Step 3: Change the root password
Now you just need to change the root password with passwd command
[root@rescue-pro /]# passwd
Changing password for user root.
Retype new password:
passwd: all authentication tokens updated successfully.
Finally, it’s time to reboot your VPS
Log in to your client area
Click services and select your server e.g Cloudpap 1
- Scroll down and click the Power button. Select NetBoot, choose local from the drop down and then click the Boot Now button.
- Click yes when prompted.
And your VPS will reboot. It can take up to 10 minutes depending on the operating system installed.
Your password has been changed. You can now access your VPS using your new password.