← All articles

Lost SSH access to your VPS — recovery steps

Locked out of SSH? Use your provider console (VNC/serial), recovery mode, or rescue ISO to fix keys, firewall, sshd config, or disk-full boot failures.

Lost SSH access is recoverable in most cases—use your cloud provider’s out-of-band console first. Do not rebuild the server until you have tried console recovery.

Step 1: Provider console

Every major VPS host offers a browser console when port 22 fails:

  • DigitalOcean — Droplet → Access → Launch Console
  • Hetzner — Server → Console
  • AWS — EC2 Instance Connect or serial console
  • Linode / Akamai — LISH console

Log in with root or your user (password login must be enabled for console if keys broke).

Step 2: Diagnose from console

sudo systemctl status ssh
sudo ss -tlnp | grep 22
sudo ufw status
df -h
FindingAction
sshd inactivesudo systemctl start ssh and check journalctl -u ssh -n 30
Disk 100% fullFree disk—sshd may fail to write logs
ufw denies 22sudo ufw allow OpenSSH or fix rule
Wrong sshd_configRevert backup, sudo sshd -t, restart sshd

Step 3: SSH key issues

  • Confirm your public key is in ~/.ssh/authorized_keys
  • Permissions: chmod 700 ~/.ssh && chmod 600 ~/.ssh/authorized_keys
  • If you only locked yourself out with a new key, paste the correct key from console

Step 4: Provider rescue / recovery

If the OS will not boot:

  • Mount disk in rescue mode
  • chroot into the filesystem and fix /etc/fstab, sshd, or networking
  • Last resort: snapshot disk, rebuild droplet, reattach volume

Prevent the next lockout

  • Keep provider console credentials saved
  • Test firewall rules before logging out
  • Use sshd -t before restarting sshd
  • Consider a second admin key or break-glass user

After you are back in

Run read-only health checks before big changes. Ohuriya AI is an AI DevOps Copilot that can help audit sshd and firewall settings—with approval on every command. About Ohuriya

Quick answers

I cannot SSH into my VPS — what do I do first?

Open your host's web console (DigitalOcean droplet console, Hetzner console, AWS EC2 serial). That works even when SSH and firewall are broken.

Could firewall rules block SSH?

Yes. ufw or cloud security groups often block port 22 after a bad rule. From console: sudo ufw status, or fix rules in the provider panel.

I changed sshd_config and now SSH fails

Boot via provider console, revert /etc/ssh/sshd_config, run sudo sshd -t, then sudo systemctl restart sshd. Always keep a second session open when editing SSH config.