Reset root password (VPS and migrated Cloud Servers)
Please use the “Print” function at the bottom of the page to create a PDF.
For Linux VPS and migrated Cloud Servers, which are managed in the Cloud Panel
In this article, you will learn how to reset the root password of your VPS or your migrated Cloud Server.
Warning
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.
Download DVD Clonezilla latest_iso
- Log in to your IONOS account.
In the title bar, click on Menu > Servers & Cloud.
Optional: Select the desired Server & Cloud contract.- Activate the desired server.
- Click on DVD drive.
- Select the Clonezilla latest_iso DVD.
- Click on Load DVD.
Boot Clonezilla from DVD
- Click on Actions > Restart.
- Click on Yes.
- Click on Actions > Open remote console.
The remote console opens in a new tab.
- Select the desired language in the Choose language window.
- In the Keyboard configuration window, select the Change keyboard layout option.
- Select the option Generic PC keyboard with 105 keys.
- In the Configuring keyboard-configuration window, select the keyboard layout.
- Select the country of origin for the keyboard.
- Select the keyboard layout.
- Select the key that is to function as AltGr (right Alt key).
- Select the Compose key.
- In the Start Clonezilla window, select the Enter_shell command line prompt option.
Reset password
To call up information on all disks, enter the following command:
user@debian:~$ sudo fdisk -l
- Determine the root partition. The name of the root partition of a migrated cloud server with AlmaLinux 9 is /dev/vda4, for example.
To mount the root partition, enter the following command:
user@debian:~$ sudo mount /dev/ROOT_PARTITION /mnt
Replace the placeholder ROOT_PARTITION with the name of the root partition of your server. Examples:Ubuntu 22.04
user@debian:~$ sudo mount /dev/vda1 /mnt
VPS with Rocky Linux 8.6 and 9:
user@debian:~$ sudo mount /dev/vda5 /mnt
VPS with Rocky Linux 8.6 and 9:
user@debian:~$ sudo mount /dev/vda4 /mntFor the next steps it is necessary to mount the directories /dev, /proc, and /sys. To do this, enter the following commands:
user@debian:~$ sudo mount --bind /dev /mnt/dev
user@debian:~$ sudo mount --bind /proc /mnt/proc
user@debian:~$ sudo mount --bind /sys /mnt/sysSet the mounted partition to a change root environment:
user@debian:~$ sudo chroot /mnt
Only applies to AlmaLinux 8 and 9 and Rockylinux 8 and 9: Open the SELinux configuration file. To do this, enter the following command:
root@debian:/home/user# vi /etc/selinux/config
Notes
- The vi editor has an insert mode and a command mode. You can call up insert mode with the [i] key. In this mode, the characters entered are immediately inserted into the text. To call up command mode, press [ESC]. If you use command mode, your keyboard input is interpreted as a command.
- To exit vi and save the file, enter the command :wq and then press Enter.
- Only applies to AlmaLinux 8 and 9 and Rockylinux 8 and 9: Press the [i] key and set the value in the SELINUX=enforcing line to SELINUX=permissive.
- Only applies to AlmaLinux 8 and 9 and Rockylinux 8 and 9: To call up command mode, press the [ESC] key.
- Only applies to AlmaLinux 8 and 9 and Rockylinux 8 and 9: To exit vi and save the file, enter the command :wq and then press Enter.
To set a new password, enter the following command:
[root@debian:/]# passwd root
- Enter the new password and repeat it.
To end access to the root file system, enter the following command:
[root@debian:/]# exit
Enter the following command:
user@debian:~$ sudo touch /.autorelabel
To ensure that all changes are correctly applied to the system files, enter the following commands:
user@debian:~$ sync
To unmount the /dev, /proc and /sys directories, enter the following commands:
user@debian:~$ sudo umount /mnt/dev
user@debian:~$ sudo umount /mnt/proc
user@debian:~$ sudo umount /mnt/sysTo mount the root partition, enter the following command:
user@debian:~$ sudo umount /mnt
Eject DVD and restart server
- Open the Cloud Panel.
- To eject the DVD, click on Clonezilla latest_iso.
- Click on Yes.
- Click on Actions > Restart.
- Click Yes.
The server is restarted. You can then log in to the server with the new password.