Get a VPS server with a 15% discount
Sale ends in
00Days
:
00Hours
:
00Minutes
:
00Seconds

Changing the root password on a Hetzner server via Rescue

Forgot the password for your Linux dedicated server? No worries — let's fix this.

First, you need to boot your dedicated server into recovery (Rescue) mode. You can do this by following this guide.

Booting the server into Rescue mode

Viewing the storage devices

Use the command to view the storage devices attached to your server.

If you are using Software RAID on your server, the output will look similar to this. Pay attention to the md devices, specifically md0, md1, md2:

lsblk output when using Software RAID

If your server does not use Software RAID, then depending on the type of storage devices, the command output will look roughly like this:

lsblk output without Software RAID

Mounting the main disk

Next, you need to mount the main disk partition. Since our test server uses Software RAID, md2 is the appropriate choice here.

Excellent.

Result of mounting the partition

Now we set a new root directory to work with the newly mounted filesystem:

Changing the password

The main part of the procedure is now complete. All that remains is to use the standard command to change the password of the required user.

Enter the new password twice.

Entering the new password with passwd

Done.

Password changed successfully

Exiting Rescue mode

You simply need to reboot the server in the cloud control panel or by using the command to exit Rescue mode. After that, you can connect to your server using the new password.

If you encounter an error like this when running the command, use the key combination to exit the additional session that was created.

Error when running the reboot command

Great. Now you can reboot your server and continue working.