Skip to content
// LINUX | July 7, 2026 | 3 min read

Reset the Root Password on Debian

Locked out of your own server does not have to mean starting over, here is how to get back in.

Reset the Root Password on Debian
deploy@server:~
deploy@server ~ $ sudo ufw status
Status: active
 
To Action From
-- ------ ----
22/tcp ALLOW Anywhere
80/tcp ALLOW Anywhere
443/tcp ALLOW Anywhere
deploy@server ~ $

Here is how to reset the root password on Debian when you are locked out and SSH is not an option. On a server that has been running quietly for a long time, this usually happens when a password from months or years ago simply got lost, or when a server changes hands and the old credentials never made it along. The fix does not need a reinstall. It needs about five minutes with the console.

What you need

  • A Hostner dedicated server running Debian
  • Access to your Hostner KVM/IPMI console (this only works through the console, not SSH)
  • A few minutes where the server can reboot

Step 1: Open the console and reboot

Log into your Hostner dashboard and open the KVM/IPMI console for your server. With the console window open, trigger a reboot from the dashboard’s power controls. Watch the console closely. The GRUB boot menu only shows for a few seconds before it boots automatically.

Step 2: Edit the boot line in GRUB

Unlike Ubuntu, Debian does not ship a curated recovery menu in GRUB by default, so editing the boot line directly is the standard way in on a Debian system. This is the same single-user mode technique that predates GRUB itself, adapted to GRUB2’s editor. When the GRUB menu appears, use the arrow keys to highlight your Debian boot entry (do not press Enter yet). Press e to edit it. You will see a block of boot parameters. Find the line starting with linux. At the end of that line, change ro to rw, then add:

~ $ init=/bin/bash

Press Ctrl+X to boot with these changes.

Step 3: Reset the root password on Debian

You should now land in a root shell, no password asked. First, remount the filesystem as writable:

~ $ mount -o remount,rw /

Then set a new password:

~ $ passwd root

Type the new password twice when asked.

Step 4: Reboot normally

Bring the system back to a normal boot:

~ $ exec /sbin/init

Or, if that hangs, force a reboot from your Hostner dashboard instead. Log in with the new password once the server is back up.

If it does not work

If the GRUB menu does not appear at all, you likely missed the short window before autoboot. Reboot again and press a key (any key) the moment the console shows POST output, then try again. If the mount -o remount,rw / command reports the filesystem is busy or fails silently, double-check you are editing the correct boot entry, some Debian installs with custom partitioning use a different root device than the default. The Debian Wiki’s GRUB2 page has background on boot parameters if you want to understand what each one does before changing it.

No ticket for this one. Five minutes in the console and you are back in as root, on your own terms.

Prevent this next time

A password manager entry for each server sounds obvious until the server has been running untouched for two years and nobody remembers where that entry went. Store the root credentials somewhere your whole team can find them, not just in one person’s head or one laptop’s browser. A shared password manager with proper access controls costs a lot less time than another five-minute trip through GRUB, multiplied by however many people might need root access down the line.

Also available for: Ubuntu, AlmaLinux. See all guides in Docs.

H

Hanna Taoufik

The Hostner team writes about servers, Linux, security, and everything that comes with running your own infrastructure, so you can skip the support ticket.