How to Recover the Root Password on Linux
This guide explains how to reset the root password on a Linux server using Rescue Mode.
This method can be used if you have lost the root password or cannot log in to the server as root.
Be careful when mounting partitions and changing system files. Using the wrong partition may prevent you from resetting the correct system password.
Step 1 – Boot the Server into Rescue Mode
Log in to the Client Area and open your server details page.
Use the Rescue Mode option to boot the server into rescue mode.
You can find more information about Rescue Mode here:
After Rescue Mode is started, log in via SSH using the rescue login details.
Booting into Rescue Mode usually takes a few minutes and should normally not take longer than 10 minutes.
If the server does not boot into Rescue Mode within 10 minutes, please open a support ticket. This usually means that the server did not boot into Rescue Mode correctly.
Step 2 – Find the Linux Root Partition
After logging in to Rescue Mode, list available disks, partitions and RAID arrays:
lsblk -f
If your server uses software RAID, also check:
cat /proc/mdstat
Look for the Linux root partition or RAID device. It is usually an ext4, xfs or similar Linux filesystem.
Examples of possible root devices:
/dev/sda3 /dev/md0 /dev/md1 /dev/md/root
The root partition name depends on your server configuration. It may be a normal disk partition such as /dev/sda3 or a RAID device such as /dev/md0. Always check your own partition layout first.
Step 3 – Mount the Root Partition
Create a temporary mount point:
mkdir -p /mnt/sysroot
Mount your Linux root partition or RAID device:
mount /dev/sda3 /mnt/sysroot
Replace /dev/sda3 with the correct root device from your server.
For example, if your root filesystem is on /dev/md0, use:
mount /dev/md0 /mnt/sysroot
Step 4 – Change Root into the Installed System
Enter your installed Linux system:
chroot /mnt/sysroot
You are now working inside your installed system from Rescue Mode.
Step 5 – Reset the Root Password
Change the root password:
passwd root
Enter the new root password twice when prompted.
If the password was changed successfully, you should see a confirmation message similar to:
password updated successfully
Use a strong password and store it safely. You will need this new password for future root logins, if root password login is enabled on your server.
Step 6 – Exit and Reboot into Normal Mode
Exit the chroot environment:
exit
Unmount the root partition:
umount /mnt/sysroot
Rescue Mode is a one-time boot. To return to the normal system, simply reboot the server from the Client Area or directly from SSH in Rescue Mode with:
reboot
After the reboot, the server should boot back into the normal operating system.
After the server boots normally, try to log in using the new root password.
If Root Login Still Does Not Work
If the password was changed but you still cannot log in as root via SSH, root password login may be disabled in the SSH configuration.
In that case, log in using another user if available or use Rescue Mode again to check your SSH configuration.
Some systems may have root password login disabled for security reasons. Resetting the root password changes the system password, but SSH access also depends on the SSH server configuration.
Verification
If you can log in to the server with the new root password after booting back into normal mode, the password reset was completed successfully.