How can I reset the root password of my Linux server?

Once you have forgotten the root password, you can no longer log into the server. We have here an explanation of how to change your root password.

You must first start your server in rescue mode .
You can connect to the loaded minimal Linux on your server via SSH.

In order to change the password, you must first mount the partition and important directories. We have listed the relevant commands for you below.

  • ssh
    You need to replace XXXXX with the server number of your server
  • mount /dev/sdXX /mnt
    Replace XX with your partition, e.g. sda1
  • mount –bind /dev /mnt/dev/
  • mount –bind /proc /mnt/proc/
  • mount –bind /sys /mnt/sys/

Now you have to switch to the chroot environment

  • chroot /mnt /bin/bash

You can now change your system passwords.

  • passwd root new-r00t-password
  • passwd administrator new-4dmin-password
  • exit
    This will take you out of the chroot environment.

You now have to unmount the mounted directories and partitions again.

  • umount /mnt/sys/
  • umount /mnt/proc/
  • umount /mnt/dev/
  • umount /mnt/

Now you can perform a reset in the myhosttech customer center so that the server no longer starts in rescue mode.

Updated on 23. February 2022

Was this article helpful?

Related Articles

Do you need support?
Deine Lösung steht noch nicht in den FAQ? Keine Sorge, wir sind für dich da.
Kontaktiere uns!