Offer Free .in, .co.in or .com domain for year one with web or WordPress hosting on a 12-month+ term, plus free migration. See the offer
VPS & dedicated

Reset your VPS root password or boot into rescue mode

Locked out of a server? Use the lightest tool that fixes it: a password reset if the password is lost, the browser console if SSH is blocked, rescue mode if the server won't boot, and a rebuild only as the last resort.

  • Updated
  • 7 min read
  • Level Intermediate

Before you start

  • Your client area login, and the VPS's name or IP address from the Services list.
  • An SSH client: Terminal on macOS or Linux, PowerShell or PuTTY on Windows. See Connect to your VPS over SSH.
  • If the server still runs, a snapshot taken first. Three on-demand snapshots are free on every VPS.
Hands-on time5 to 30 minutes
DowntimeOne or two reboots

Password reset, console or rescue mode: pick the right tool

What's wrongUseYour data
Root password lost or never savedA. Reset root passwordKept
A firewall or SSH change locked you out, server still runningB. Browser consoleKept
Won't boot, stops in emergency mode, or the disk is fullC. Rescue modeKept
Beyond repair, or you want a clean startD. RebuildErased

Option A: Reset the root password

  1. Open the VPS in the client area

    Go to Servicesyour VPSReset root password. Applying the new password can involve a quick restart, so do it when a minute of downtime is acceptable.

  2. Choose a strong password and save it

    Use at least 16 characters, or accept the generated one, and store it in a password manager. We never ask for it, in tickets or anywhere else.

  3. Log in

    ssh root@203.0.113.42

Using key-only SSH? If you turned password logins off, as Secure a new Linux VPS recommends, the new password works in the console but not over SSH. To add a key from a new computer, allow passwords for a minute, then switch them off again. If root login is off as well, install the key for your sudo user rather than root:

# on the server, in the browser console
echo 'PasswordAuthentication yes' > /etc/ssh/sshd_config.d/00-allow-passwords.conf
systemctl reload ssh        # AlmaLinux / Rocky: systemctl reload sshd

# on your computer: your sudo user, or root if root login is still allowed
ssh-copy-id deploy@203.0.113.42

# back on the server: remove the exception
rm /etc/ssh/sshd_config.d/00-allow-passwords.conf && systemctl reload ssh

The file is named 00-allow-… so it sorts ahead of 00-hardening.conf: SSH uses the first value it reads, and files in that folder are read in alphabetical order. AlmaLinux and Rocky 8 don't read the folder, so on those change the PasswordAuthentication line in /etc/ssh/sshd_config instead.

Option B: Use the browser console

Servicesyour VPSConsole opens the server's screen and keyboard in a browser tab, as if a monitor were plugged in. It doesn't use SSH or the network, so it works when a firewall rule or a broken SSH config has shut you out.

  • Log in as root with the password. SSH keys don't apply at the console.
  • The console uses a US keyboard layout. If pasting doesn't work, type the command.
  • A black screen is usually just blanking: press Enter.

Then undo whatever locked you out. These commands cover the usual culprits:

# firewall: is SSH allowed?
ufw status numbered
ufw allow 22/tcp

# SSH config valid? then restart and check the service
sshd -t && systemctl restart ssh
systemctl status ssh --no-pager

# banned by fail2ban? (your own public IP)
fail2ban-client set sshd unbanip 198.51.100.7

Option C: Boot into rescue mode

Rescue mode starts the VPS from a small temporary Linux system, with your own disk attached but not in use. From there you can repair files the broken system won't let you reach.

  1. Enable rescue and connect

    Choose Servicesyour VPSRescue. The VPS restarts, and the panel shows the temporary root password. Connect as usual. SSH will warn that the host key has changed, which is expected here, so clear the old key first:

    ssh-keygen -R 203.0.113.42
    ssh root@203.0.113.42
  2. Find your disk

    lsblk -o NAME,FSTYPE,LABEL,SIZE
    NAME     FSTYPE  LABEL            SIZE
    vda                                80G
    ├─vda1   ext4    cloudimg-rootfs  79.9G   ← your system
    ├─vda14                            4M
    └─vda15  vfat    UEFI             106M

    Your system is the largest ext4 or xfs partition. If its type is LVM2_member, run vgchange -ay and use the /dev/mapper/…-root volume that lvs lists.

  3. Mount it and step inside

    mount /dev/vda1 /mnt
    for d in dev proc sys run; do mount --rbind /$d /mnt/$d; done
    chroot /mnt /bin/bash

    Your prompt now acts on the installed system, so commands such as passwd and nano change your server, not the rescue system.

  4. Fix the problem

    # forgotten password
    passwd root
    touch /.autorelabel          # AlmaLinux / Rocky only: SELinux relabels on next boot
    
    # boots into emergency mode: check fstab against the real UUIDs
    blkid
    nano /etc/fstab              # fix or comment out the bad line, or add "nofail"
    findmnt --verify
    
    # SSH won't start: show the broken line
    sshd -t
    
    # disk full: find what filled it
    df -h /
    du -xh --max-depth=1 / | sort -h | tail
  5. Leave rescue mode

    exit
    umount -R /mnt

    Then turn rescue off from the same Rescue page so the VPS boots from its own disk. Run ssh-keygen -R once more before reconnecting, because the host key changes back.

Option D: Rebuild (reinstall) the OS

A rebuild erases the whole disk. Websites, databases, mail and settings are gone afterwards. If the server still boots, take a snapshot first. If it doesn't, use rescue mode to copy what you need off it, for example with rsync or scp to another machine.

Go to Servicesyour VPSRebuild, choose one of the 12 OS images (Ubuntu, Debian, AlmaLinux, Rocky Linux, CentOS Stream, Fedora or Windows Server), set a new root password and confirm. The server is usually ready within minutes. Then work through Secure a new Linux VPS before you restore your data.

If you pay for the backups add-on (+20%, daily copies kept for 14 days), you can also roll back to one of those instead of rebuilding from scratch.

On a dedicated server

Dedicated servers include IPMI, which gives you the machine's own console (KVM-over-IP), power control and virtual media. The same ideas apply:

Console

Open the KVM console from IPMI and work as in Option B. It shows the screen from power-on, so you can also watch the boot and choose a GRUB entry.

Rescue

Attach a live Linux ISO through virtual media, or ask us to boot one. Disk names differ: NVMe partitions look like /dev/nvme0n1p2, and software RAID needs mdadm --assemble --scan before you mount /dev/md0.

Troubleshooting

SSH says "REMOTE HOST IDENTIFICATION HAS CHANGED"

Expected after entering or leaving rescue mode, or after a rebuild: the server presents a different key. Run ssh-keygen -R 203.0.113.42 and connect again. If you see it when nothing has changed, don't log in; open a ticket.

The console rejects a password I know is right

Usually the keyboard: the console expects a US layout, so symbols such as @, " and # may land on different keys. Check Caps Lock, or reset to a temporary password of letters and digits, log in, and change it with passwd.

mount says "unknown filesystem type 'LVM2_member'"

The system disk uses LVM, so mount the logical volume rather than the partition. Run vgchange -ay to activate it and lvs to list the volumes, then mount the root one, for example mount /dev/mapper/almalinux-root /mnt.

AlmaLinux still refuses the password I set in rescue

SELinux is blocking the changed password file. Boot rescue again, mount and chroot as above, run touch /.autorelabel, then leave rescue. The next boot relabels the disk and takes a few minutes longer than usual.

The server stops at "You are in emergency mode"

A line in /etc/fstab points at a disk or UUID that no longer exists, often after removing a volume. Fix it from rescue (step 4), or add nofail to non-essential mounts so a missing disk can't stop the boot again.

Was this guide helpful?Your answer stays in this browser; nothing is sent unless you write to us below.

Related guides

All 16 guides

Still stuck? Ask an engineer.

Tickets and email are answered 24/7 in English and Hindi. Include the VPS name, what changed last and the exact error or what the console shows.