If you can no longer access your server because you lost your root password, you can regain access by changing the root password on the server.
To change the root password in Hetzner Console, select the server, navigate to "Rescue" and select "Reset Root Password".
To change the root password via the rescue system, do the following:
-
Enable the rescue system
As explained in this getting started:
- Select the server
- Navigate to "Rescue" and click on "Enable rescue & power cycle"
- After the reboot, connect to the server as root user.
-
Create a chroot environment
Run
lsblkand identify the name of the root partition (e.g.sda1).Mount the root partition into
/mntand create the chroot environment:Replace
sda1with the name of your root partition.mount /dev/sda1 /mnt chroot-prepare /mnt chroot /mntYou can now navigate through the file structure of your server's primary disc.
-
Change the root password
passwdAfter you changed the password, you can run
exitto leave the chroot environment.
-
Restart the server
Restart your server to leave the rescue system:
reboot
After reboot, you should be able to log in as root using the new password.