Hetzner Robot

How to reset the root or Windows password on Hetzner

The root password on a Hetzner Linux server is reset through the Rescue System, and the files on the disks stay in place. The Windows administrator password is harder: some cases you can solve yourself, and with the rest we will help.

  • Time: 15 minutes
  • Level: Intermediate

In short

  • First, try the password from the server delivery ticket: if you have not changed it, it works.
  • Linux: boot the Rescue System, mount the system partition, run chroot-prepare /mnt, chroot /mnt and passwd, then reboot.
  • Windows: Robot has no reset. If you have another administrator login, change the password with the net user command. If not, the options are a reinstall through us or an offline reset with a KVM console.
  • Do not send the new password to anyone, including us in a ticket.
Contents
  1. First, make sure the password is really lost
  2. Linux: resetting the root password through Rescue
  3. How to check the new password
  4. If you logged in with an SSH key and lost it
  5. Windows: what you can do about the administrator password
  6. If something goes wrong
  7. FAQ

You will need

First, make sure the password is really lost

The password we delivered the server with is in the delivery ticket. If you have not changed it, it works. Most often, the login fails because of small things:

  • the password was copied with a space at the start or at the end;
  • a different keyboard layout was on when you typed it by hand;
  • on Windows, the username was typed wrong: take it from the ticket, it is usually Administrator. More in the article on how to connect via RDP;
  • the Robot or Rescue System password was entered instead of the server password. These are three different passwords.

If you changed the password after delivery, we do not know it, and a reset is the only option.

Linux: resetting the root password through Rescue

The server reboots twice: into Rescue and back into its own system. While you reset the password, the sites and programs on it are down. The files on the disks stay.

  1. Boot the server into the Rescue System

    In Robot, open Serveryour serverRescue, choose Linux and enable Rescue. Copy the password that Robot shows, and within 60 minutes reboot the server on the Reset tab. This step is covered in detail in the article on how to enable Rescue.

    The Rescue tab in Hetzner Robot before activation: Linux (Debian Trixie/stable) is selected under Operating system; this option and the Activate rescue system button are highlighted
    On the Rescue tab, select Linux and click Activate rescue system
  2. Log in to Rescue via SSH

    ssh root@203.0.113.10

    Use your server’s IP and enter the Rescue password, the one Robot showed when you enabled it. If SSH says the server key has changed, run ssh-keygen -R 203.0.113.10 and connect again: Rescue has its own key.

    The Rescue tab in Hetzner Robot right after activation: the activation message and the line with the root password for Rescue (hidden in the screenshot); the password line is highlighted
    This is the password for logging in to Rescue. You set the new root password yourself in step 6
  3. Find the system partition

    lsblk -o NAME,SIZE,TYPE,FSTYPE
    cat /proc/mdstat

    If the server has software RAID, the system is usually on the /dev/md2 array. Without RAID, it is usually the last or second-to-last partition of the disk, for example /dev/nvme0n1p3 or /dev/sda3. If FSTYPE shows LVM2_member, run vgchange -ay and take the volume from /dev/mapper/, for example /dev/mapper/vg0-root. How to read the lsblk output is shown in the article on Rescue.

  4. Mount the partition

    mount /dev/md2 /mnt
    ls /mnt

    Replace /dev/md2 with your partition. If /mnt contains the etc, root and usr folders, you have mounted the system. If there are only files like vmlinuz and a grub folder, this is the boot partition: unmount it with umount /mnt and try another one.

  5. Switch into the system with chroot

    chroot-prepare /mnt
    chroot /mnt

    The first command mounts the system folders, the second switches you into the system on the disk. From now on, your commands run in your own system.

  6. Set a new password

    passwd

    Enter the new password twice. The characters do not show as you type; that is by design. If the password has changed, Debian and Ubuntu reply passwd: password updated successfully, and AlmaLinux and Rocky Linux reply passwd: all authentication tokens updated successfully. To change another user’s password, add the username: passwd ubuntu.

    AlmaLinux, Rocky Linux and CentOS Stream: SELinux

    These systems have SELinux enabled, and after a password change from Rescue it may not let you in with the new password. Before you leave chroot, run:

    touch /.autorelabel

    The first boot after this takes longer than usual: the system relabels the files for SELinux and then reboots once more on its own.

  7. Exit and reboot the server

    exit
    reboot

    exit takes you back to Rescue, and reboot restarts the server. Rescue is enabled for one boot only, so the server boots into its own system.

When the server has booted, check that the new password works.

How to check the new password

Connect to the server as root with the new password. SSH will warn about a changed server key again, because now your own system is answering: remove the key with ssh-keygen -R and the server’s IP, then connect again.

Keep the new password in a password manager and do not send it to anyone, including us in a ticket: we do not need it to help with the server.

If you logged in with an SSH key and lost it

A lost key is also replaced through Rescue, and you do not need chroot for it. First, create a new key pair on your computer:

ssh-keygen -t ed25519

The public key appears in the id_ed25519.pub file in your user’s .ssh folder. Then boot the server into Rescue, mount the system partition (steps 1–4 above) and open root’s key file:

mkdir -p /mnt/root/.ssh
nano /mnt/root/.ssh/authorized_keys

Paste the line from id_ed25519.pub (it starts with ssh-ed25519) and delete the line of the lost key. Save the file with Ctrl+O and Enter, and exit with Ctrl+X. If nano is not available, mcedit opens the same file: F2 saves, F10 exits. Then set the permissions and reboot the server:

chmod 700 /mnt/root/.ssh
chmod 600 /mnt/root/.ssh/authorized_keys
reboot

After the server boots, connect with the new key, as described in the article on connecting via SSH.

Windows: what you can do about the administrator password

Robot has no button to reset a Windows password, and the Rescue System is Linux, so you cannot change the password from it with standard Windows tools. What works depends on whether you still have any way to log in.

SituationWhat to do
You have another user with administrator rights, or an open RDP sessionChange the password yourself: open Command Prompt as administrator and run net user Administrator *. Windows asks for the new password twice.
You cannot log in, and the files on the server can be saved or are not neededRetrieve the files through the Rescue System: it can usually read a Windows disk. Then ask us in a ticket to reinstall Windows. A reinstall erases everything on the disks.
You cannot log in, and the files and programs must stay in placeYou can clear the password from Rescue with chntpw, then log in with an empty password through the KVM console and set a new one. This method is for those who are comfortable with Linux; the steps are below.
The disk is encrypted with BitLockerWithout the BitLocker recovery key, neither Rescue nor the console will help: a reinstall is the only option.
Offline Windows password reset through Rescue and the KVM console

This method changes the Windows system file that holds the user accounts (SAM), so save a copy of it first. It works for a local account, such as Administrator, and does not work with an encrypted disk.

  1. Order a KVM console from us for the time you need: you will need it at the end.
  2. Boot the server into Rescue and find the Windows partition: in the output of lsblk -o NAME,SIZE,FSTYPE it is marked ntfs. If the mount or chntpw command later reports that a program is not found, install both: apt update && apt install -y ntfs-3g chntpw.
  3. Mount the partition for writing and save a copy of the accounts file:
    mount -t ntfs-3g /dev/nvme0n1p2 /mnt
    cd /mnt/Windows/System32/config
    cp SAM SAM.bak
  4. List the accounts and clear the password of the one you need:
    chntpw -l SAM
    chntpw -u Administrator SAM
    In the menu, choose 1 - Clear (blank) user password, then q, and answer y when asked whether to write the changes.
  5. Unmount the partition and reboot the server: cd / && umount /mnt && reboot.
  6. In the KVM console, log in as Administrator with an empty password and set a new one right away. Windows does not let you in via RDP with an empty password: by default, such a login is allowed only from the server’s own screen.

If you are not sure which way is yours, describe the situation in a ticket or on Telegram, and we will tell you what will be quicker.

If something goes wrong

What you seeWhat to do
passwd: Authentication token manipulation errorThe partition is mounted read-only. Leave chroot with exit, run mount -o remount,rw /mnt and repeat steps 5 and 6.
chroot: failed to run command '/bin/bash': No such file or directoryThe wrong partition is mounted, for example the boot partition. Unmount it with umount -R /mnt and mount another one: the one where /mnt has an etc folder.
SSH does not accept the new password: Permission deniedRoot login with a password may be disabled in the SSH settings. Check from Rescue: grep -Ei 'PermitRootLogin|PasswordAuthentication' /mnt/etc/ssh/sshd_config /mnt/etc/ssh/sshd_config.d/*.conf. If it says no or prohibit-password, log in with an SSH key, as described above: that is also more secure.
The server does not come back online after the rebootWait 15 minutes: on AlmaLinux and Rocky Linux, the first boot after /.autorelabel takes a long time. If it still does not appear, boot Rescue again and check the system, or ask for a KVM console.
The Windows partition will not mount: Windows is hibernated, refused to mount or Metadata kept in Windows cache, refused to mountWindows was shut down into hibernation or with Fast Startup, so the partition cannot be mounted for writing. Mount it with the remove_hiberfile option: mount -t ntfs-3g -o remove_hiberfile /dev/nvme0n1p2 /mnt. The saved Windows session is lost, and changes Windows had not yet written to the disk may be lost too. If the server holds important data, message us in a ticket first.
Robot does not open from your networkThis is a restriction on your internet provider’s side. Message us in a ticket or on Telegram, and we will boot the server into Rescue for you.

If your server is with OVH, the procedure is different: see Rescue and IPMI on an OVH server.

FAQ

Can you send me my root password?
The password we delivered the server with is in the delivery ticket. If you have changed it, we do not know it: only a reset following this guide will help.
Will resetting the password delete my files?
No. Rescue and the passwd command change only the password; your files and programs stay in place.
I forgot my Robot password, not the server password. What should I do?
We change the password of the Robot login: write to us in a ticket, and we will issue a new one. The guide above is for passwords on the server itself.

Did this guide help?

Questions?