Recovery of root password on Debian 9

Estimated reading time: 2 min

Introduction

In this article, we will learn how to recover the password of the root user account on the Debian 9 operating system.

Debian 9

Prerequisites

Recover of root password

Step 1: Log into the KVM console

In order to change the root password you will need to log into the KVM console, depending on which server type you are using the methods may differ.

If you are using Cloud VPS please refer to this article

If you are using a dedicated server with iDRAC please refer to this article

If you are using a Supermicro servers please refer to this article

For VPS users navigate to under the VPS service details page, from there you can click Console, this will open the KVM console on a new browser.

Step 2: Reboot the machine

While you have your KVM console open, reboot the server to get the GRUB menu.

Dedicated server users will have to open Server Power Control

right after that click reboot to restart your server.

VPS users: Open the service details page of the VPS and click on the reboot button

Note: After rebooting your server quickly go to the KVM console as GRUB menu waits only a few seconds before booting OS.

Step 3: Modify boot parameters

After rebooting the VM quickly switch to KVM console and keep pressing the ESC.

You will need to do this very quickly to get the GRUB menu.

 Note: If you missed the grub screen, go ahead and reboot your server again.

In GRUB menu, press E to edit the GRUB parameters

In GRUB edit mode, find the line which starts with linux /boot/ , next you will need to navigate to the end which should show ro quiet , add a space and type the following:

init=/bin/bash

it should look like this:

linux          /boot/vmlinuz-4.9.0-19-amd64 root=/dev/sda1 ro  quiet init=/bin/bash

Once done, press CTRL + X or F10 to boot in single-user mode.

Step 4: Reset password

Next you will need to change the acces right from read-only to read-write, to do so type the following command:

mount -o remount, rw /

Now we can change the root password, run the following command to change your password:

passwd

to change your password.

After that you can reboot the server with the following command:

reboot -f

Conclusion

In this tutorial we have shown how to recover the root password for Debian 9.

Was this article helpful?
Dislike 0
Views: 3298

Reader Interactions

Leave a Reply

Your email address will not be published. Required fields are marked *