Blog / Tutorials

Locked Out of Your VPS? The Recovery Order That Works

By Danylo ChernovNovember 30, 20266 min read

If you are locked out of a VPS, run 3 checks from your own machine first (ping, nc -vz IP 22, ssh -vvv), because they tell you which of three problems you have, and then recover in this order: the browser console, a root password reset from the dashboard, a backup restore or address swap, and finally a redeploy, which on the smallest plan costs about 1.4 cents an hour. Most lockouts are a firewall rule or an sshd_config typo, and the console fixes both because it does not go through SSH at all.

The server is usually running perfectly. It just will not let you in.

Step zero: what kind of locked out is it?

ping -c 3 YOUR_IP
nc -vz YOUR_IP 22
ssh -vvv root@YOUR_IP
  • No ping and no port. The machine is off, gone, or a rule is dropping everything. Check the panel first: a server whose balance ran out is suspended, not deleted, and a stopped server looks exactly like this. Some firewalls also drop ping on purpose, so treat this as a hint.
  • Ping works, port 22 refuses or hangs. Connection refused means nothing is listening, usually because sshd failed to start. A hang means a firewall is silently dropping the packets. This is the common case.
  • Port answers, authentication fails. The daemon is fine and the problem is your key, your password or the auth config. The -vvv output usually names the reason.
Tip: Permission denied (publickey) means the server is working as configured and does not accept your key. Connection refused means nothing is listening. They need completely different fixes.

Step one: the browser console

A browser console attaches to the machine's virtual display, the same thing a monitor plugged into it would show. Vultr describes theirs as a noVNC terminal that provides direct access to an instance, and Hetzner's console works the same way. It does not use SSH or port 22 and does not care what your firewall says. If the machine is powered on, you get a login prompt.

On NoctHost the console is on the server page for Vultr and Hetzner servers. Log in as root with your password and look:

systemctl status ssh        # is the daemon running? (sshd on non-Debian systems)
sshd -t                     # does the config parse?
ufw status verbose          # what is the firewall doing?

This is why the root password stays required when you deploy with an SSH key: a key is no use at a text console. Disabling password login inside the server only affects SSH, so console login still works.

Step two: reset the root password

If the problem is a lost password and SSH itself still answers, you do not need a console. Linux servers deployed here carry one extra recovery key of ours, shown on the server page. While it is in place, you choose a new root password in the dashboard and it is set on the running server: nothing is erased and the IP stays the same.

That path needs SSH to be reachable, so it does not help if you firewalled port 22 or broke sshd. For those cases, servers on Hetzner and Linode can also have the password reset by the provider from the server page. On a Vultr server, the other route is a reinstall from the dashboard, which erases the disk but keeps the IP.

Step three: restore a VPS backup or swap the address

Restore a backup, if you took one before the change. On Vultr servers the dashboard takes a full-disk backup and restores it. You lose what changed since and get a working machine back.

Swap the address. On Vultr, DigitalOcean and Hetzner servers, the dashboard can rebuild the server from a fresh snapshot of its own disk with a new root password. Data survives; the IPv4 changes, so update DNS afterwards.

Step four: redeploy the VPS

Unglamorous and often correct. If the server was set up by a script, or the data lives somewhere else, a new server is a few minutes away and costs cents at hourly rates. Debugging a broken sshd without a console can take an hour.

The deciding question is whether the machine is reproducible. If it is (a compose file, an Ansible playbook, a shell script you kept), redeploy without hesitating. If it is a year of undocumented changes made by hand, spend the hour, and then write the script while the lesson is fresh.

The mistakes that cause this

Editing sshd_config from your only session. Open a second connection first and keep it. If the change breaks the daemon, the old session stays alive and you can revert.

Skipping sshd -t. It validates the configuration without applying it and catches nearly every fatal typo.

Enabling the firewall before allowing SSH. The ufw manual notes that ufw's default incoming policy is deny and that it prompts when you enable it over SSH; that prompt is the warning. Run ufw allow 22/tcp first, or ufw limit 22/tcp, which also denies an address that opens 6 or more connections within 30 seconds.

Changing the SSH port and forgetting the firewall. Allow the new port, restart sshd, test the new port from a second window, and only then remove the old rule. Since Ubuntu 22.10, [sshd is started by ssh.socket](https://discourse.ubuntu.com/t/sshd-now-uses-socket-based-activation-ubuntu-22-10-and-later/30189), so a port change also needs systemctl daemon-reload and systemctl restart ssh.socket before the new port answers.

Disabling password login before testing the key. Test with ssh -o PasswordAuthentication=no first, as described in hardening SSH on a VPS. If that works, the key is genuinely installed.

Making it cheap next time

Take a backup before touching SSH, the firewall or the kernel. It turns a recovery afternoon into a restore.

Keep the build reproducible. The difference between "redeploy" and "disaster" is whether the machine can be rebuilt from something written down.

Keep the root password in a password manager. On Linux servers we keep no readable copy of it, and it is exactly what the console asks for. Every plan on the price list, including the Ubuntu default image, deploys with a root password and an optional SSH key.

Spin one up in about a minute

Email signup, pay with crypto or card, hourly billing. Trying a box costs cents: destroy it when you are done.

Deploy a server

Frequently asked

Can support reset my root password?
You can do it yourself from the server page while our recovery key is on the machine and SSH answers. Otherwise, Hetzner and Linode servers have a provider reset on the server page, and Vultr servers can be reinstalled. Support can point you to the right path, but there is no stored copy of the password to read back.
Which providers have a browser console here?
Vultr and Hetzner servers have one on the server page. On DigitalOcean and Linode servers, the recovery key, the Linode password reset and the DigitalOcean address swap cover the same lockouts.
Does the console work if I disabled password SSH login?
Yes. That setting applies to the SSH daemon; the console is a local login on the machine and is unaffected.
I changed the SSH port and locked myself out: now what?
Use the console and check ufw status and the Port line in your sshd config. Almost always the port changed and the firewall rule did not. Without a console, the address swap or a redeploy gets you a working machine.
Is rebooting worth trying?
Once. It fixes a hung daemon and nothing else, and costs nothing. If it does not help, stop rebooting and use the console or a reset.

Keep reading