Resetting the root password of a Dedicated Server or Bare Metal Server (AlmaLinux 8, AlmaLinux 9, Rocky Linux 8, and Rocky Linux 9)
Please use the “Print” function at the bottom of the page to create a PDF.
Valid for: Dedicated Servers and Bare Metal Servers managed in the Cloud Panel
This article explains how to reset the root password of a Dedicated Server or Bare Metal Server with AlmaLinux 8, AlmaLinux 9, Rocky Linux 8, or Rocky Linux 9 using the Rescue System.
Requirements
- The server is switched on.
- You have created an image of the server in question.
How to reset the root password of your server:
Log in to your IONOS account.
Click Menu > Servers & Cloud in the title bar.
Optional: Select the desired Server & Cloud contract.
In the Infrastructure > Servers section, select the desired server.
Click Actions > Restart.
Activate the Rescue System method.
Click Yes.
The server boots into the Rescue System.
Establish a network connection to your server using SSH. The login details are displayed in the Features section. If you use the Microsoft Windows operating system, you can use PuTTY to establish an encrypted network connection to your server. For instructions on establishing an encrypted network connection to your server from your computer, see the following articles:
Establishing an SSH connection to your Linux server from a Microsoft Windows computer
Establishing an SSH connection to your Linux server from a Linux computer
To display information about all disks, enter the following command:
rescue:~# fdisk -l
Determine the root partition. Pay attention to the size of the partition. Depending on the operating system, the root partition of a Dedicated Server or Bare Metal Server with software RAID is named md126, md125, md127, or md2, for example. With hardware RAID, the name is often /dev/sda4, and with NVMe drives, it is /dev/nvme0n1p3, for example. Examples:
Software RAID:
Disk /dev/md125: 888.66 GiB, 954195574784 bytes, 1863663232 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 131072 bytes / 131072 bytesHardware RAID:
/dev/sda4 11718656 1874327551 1862608896 888.2G Linux filesystem
To mount the root partition, adapt the following command and then enter it. Replace the placeholder MY_ROOT_PARTITION with the name of the root partition of your server. The name may differ from the examples listed below:
rescue:~# mount /dev/MY_ROOT_PARTITION /mnt
Examples:
Software RAID:
rescue:~# mount /dev/md125 /mnt
or
rescue:~# mount /dev/md126 /mnt
or
rescue:~# mount /dev/md127 /mnt
or
rescue:~# mount /dev/md2 /mnt
Hardware RAID:
rescue:~# mount /dev/sda4 /mnt
For the next steps, you need to mount the /dev, /proc, and /sys directories. To do this, enter the following commands:
rescue:~# mount --bind /dev /mnt/dev
rescue:~# mount --bind /proc /mnt/proc
rescue:~# mount --bind /sys /mnt/sys
Switch to a chroot environment on the mounted partition:
rescue:~# chroot /mnt
To set a new password, enter the following command:
rescue:/# passwd
Enter the new password and repeat it.
If SELinux is enabled (the default on Rocky Linux and AlmaLinux), enter the following command:
rescue:/# touch /.autorelabel
Exit the chroot environment. To do this, enter the following command:
rescue:/# exit
Unmount the partitions. To do this, enter the following command:
rescue:~# umount -R /mnt
Open the Cloud Panel.
Click Actions > Restart.
Activate the Current operating system method.
Click Yes.
The server restarts. You can then log in to the server with the new password.