Resetting the root password of a VPS or a migrated Cloud Server (Debian and Ubuntu)
Please use the “Print” function at the bottom of the page to create a PDF.
For Linux VPS and migrated Cloud Servers with Debian 11, Debian 12, Ubuntu 22.04 and Ubuntu 24.04, which are managed in Cloud Panel
In this article you will learn how to reset the root password of a VPS or a migrated cloud server on which Debian 11, Debian 12, Ubuntu 22.04 or Ubuntu 24.04 is installed.
Caution
These instructions list steps that can lead to data loss if performed incorrectly. Therefore, always create a backup before resetting the root password.
Requirements
The server is switched on.
You have created a backup of the server in question.
Load Rescue System
- Log in to your IONOS account.
Click on the Server & Cloud tile. If you have multiple server contracts, select the desired contract.
- Activate the desired server in the Infrastructure > Server area.
- Click on DVD drive.
- Activate the Gparted latest_iso DVD.
- Click on Load DVD.
- Click on Yes.
The server is restarted and the DVD is loaded. This may take a moment.
Starting the rescue system
- Click on Action > Open remote console.
- Select GParted Live (Default Settings) from the menu.
- Select any policy and confirm it with OK.
- Select a language. The default is 33 for English.
- Enter 0 for the start method.
Change password
- Close the GParted window by clicking on the black rectangle.
- Start the Terminal program.
To switch to the root user, enter the following command:
user@debian:$ sudo su
Read the hard disc/partition layout with the lsblk command.
user@debian:$ lsblk
Note
The name of the root file system is required for the next steps. This is usually the largest partition. In this example, vda is the name of the virtual hard disk and vda 1 is the root file system.
To mount the root file system, enter the following command and replace the placeholders:
root@debian:/home/user# mount /PATH/PARTITION /mnt
Example:
root@debian:/home/user# mount /dev/vda1 /mnt
Check whether loading was successful by executing the lsblk command again. In the example below, the current mount point /mnt is listed in the line vda1.
root@debian:/home/user# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
loop0 7:0 0 423M 1 loop /usr/lib/live/mount/rootfs/filesystem.squashfs
/run/live/rootfs/filesystem.squashfs
sr0 11:0 1 488M 0 rom /usr/lib/live/mount/medium
/run/live/medium
vda 254:0 0 240G 0 disc
├─vda1 254:1 0 239.9G 0 part /mnt
├─vda14 254:14 0 3M 0 part
└─vda15 254:15 0 124M 0 partChange to the root file system with the command chroot /mnt.
root@debian:/home/user# chroot /mnt
To start the password change, enter the following command:
root@debian:/home/user# passwd root
- Enter the new password and repeat it.
Note
While you are entering the new password, it will not be displayed for your protection. After you have entered and confirmed your desired character string twice, the password is changed.
Caution
Finally, carry out the following steps before switching back to your regular operating system. Failure to do so may result in data loss.
Terminate access to the root file system with the exit command.
[root@debian:/]# exit
To ensure that all changes are correctly applied to the system files, enter the following command:
user@debian:~$ sync
To unmount the root file system, enter the command below. Replace the placeholders.
umount /PATH/PARTITION
Example:
root@debian:/home/user# umount /dev/vda1
To check whether the unmount was successful, execute the lsblk command. If your root file system is no longer followed by /mnt, you have successfully unmounted the file system.
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
loop0 7:0 0 423M 1 loop /usr/lib/live/mount/rootfs/filesystem.squashfs
/run/live/rootfs/filesystem.squashfs
sr0 11:0 1 488M 0 rom /usr/lib/live/mount/medium
/run/live/medium
vda 254:0 0 240G 0 disc
├─vda1 254:1 0 239.9G 0 part
├─vda14 254:14 0 3M 0 part
└─vda15 254:15 0 124M 0 part
Eject DVD and restart server
- Switch back to Cloud Panel.
- In the Infrastructure > Server area, click on the gparted latest_iso DVD.
- Click on Yes.
- Click on Actions > Restart.
- Click on Yes.
The DVD is ejected and the server is restarted. This may take a moment.