Skip to main content

Linux - SSH Password Reset

Purpose

This guide describes how to reset a forgotten password for the root user on a Debian VPS hosted by Hicoria.

It is intended for situations where:

  • You cannot log in via SSH.
  • You have access to the VPS administration panel.
  • A web-based VPS console is available.
  • You can access GRUB during system startup.

    Warning: Password reset requires console or server access. Anyone who can obtain a root shell effectively has full access to the system.

1. Access the VPS Console

Log in to the Hicoria administration panel and open the management interface for the relevant VPS.

Hicoria provides a web console for VPS instances, which can be used for maintenance tasks and custom operating-system installations.

If the server is running, restart it.

2. Open GRUB

During startup, display the GRUB menu.

If the menu does not appear automatically, try repeatedly pressing:

Esc

Alternatively, try:

Shift

In the GRUB menu, select the standard Debian entry and press:

e

This opens the boot configuration for the selected entry.

3. Modify the Kernel Parameters

Note: Changes made in GRUB using the e key are temporary and apply only to the current boot. The init=/bin/bash parameter is not permanently written to the GRUB configuration. After restarting the VPS, the system will boot normally.

Find the line beginning approximately with:

linux /boot/vmlinuz-...

Near the end of this line, you will usually find parameters similar to:

ro quiet

Change:

ro

to:

rw

Then append the following parameter to the end of the line:

init=/bin/bash

The resulting section may look like this:

linux /boot/vmlinuz-... root=... rw quiet init=/bin/bash

Do not remove any parameters that are already present. Only change ro to rw and add init=/bin/bash.

4. Boot the System

Press:

Ctrl + X

or:

F10

The system should boot directly into a root shell.

You should see a prompt similar to:

root@(none):/#

5. Remount the Root Filesystem as Read-Write

For verification, check how the root filesystem is mounted:

mount | grep ' / '

If it is mounted as read-only, remount it as read-write:

mount -o remount,rw /

6. Set a New Password

Run:

passwd root

The system will ask you to enter the new password twice:

New password:
Retype new password:

Characters are not displayed while entering the password. This is normal.

After the password has been changed successfully, you should see a message similar to:

passwd: password updated successfully

7. Save the Changes and Restart

Flush pending writes to disk:

sync

Then restart the server:

reboot -f

If reboot -f does not work, try:

exec /sbin/reboot -f

8. Log in via SSH

After the system has booted, log in using the new password.

Instructions for connecting via SSH are available here.

9. Verify Access

After logging in, verify that you are logged in as root:

whoami

Expected output:

root

You can also check the system using:

hostname

and:

uptime

Resetting the Password of Another User

If you do not need to reset the root password but instead need to reset the password of another user, such as admin, run:

passwd admin

To list existing users, use:

cut -d: -f1 /etc/passwd

If Root Still Cannot Log In via SSH

Resetting the password does not necessarily enable root login through SSH.

Check the configured PermitRootLogin setting:

grep -E '^[# ]*PermitRootLogin' /etc/ssh/sshd_config

You can also check the effective SSH configuration:

sshd -T | grep permitrootlogin

For example, if the result is:

permitrootlogin no

root login via SSH is disabled.

Modern Debian versions commonly use:

permitrootlogin prohibit-password

This allows root authentication using an SSH key but disables password-based root logn.

In this situation, it is preferable to use a regular administrative user with sudo:

ssh admin@SERVER_IP_ADDRESS

Then switch to a root shell:

sudo -i