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 refusedmeans nothing is listening, usually becausesshdfailed 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
-vvvoutput usually names the reason.
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.