1. Home
  2. Own server
  3. CentOS
  4. How can I reset the root password of my Linux server?
  1. Home
  2. Own server
  3. Debian
  4. How can I reset the root password of my Linux server?
  1. Home
  2. Own server
  3. Ubuntu
  4. How can I reset the root password of my Linux server?

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 root@XXXXX.hostserv.eu
    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.
(replace the password here with your own new password)

  • passwd root NEW_ROOT_PASSWORD
  • passwd administrator NEW_ADMINISTRATOR_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 7. March 2023
Was this article helpful?

Related Articles

Benötigst du Support?
Deine Lösung steht noch nicht in den FAQ? Keine Sorge, wir sind für dich da.
Kontaktiere uns!