Engineering notes

Recovering a VPS when SSH fails

When SSH, networking or a firewall rule fails, a console is the way back into Linux. How to diagnose and repair the server safely.

By Vozora · Published

Recovering a VPS when SSH fails

SSH is usually the front door to a VPS. A bad firewall rule, broken network configuration or failed boot can close it instantly. Serial console VPS recovery gives you an out-of-band path to the machine: a text console connected to the virtual server rather than its network interface.

That distinction matters. If the server still has power but cannot answer on its public IPv4 address, restarting it repeatedly will not fix an iptables mistake, an invalid Netplan file or a service that has bound the wrong interface. A serial console lets you log in locally, inspect the state of the host and undo the change.

On a self-managed VPS, this is not a substitute for backups or change control. It is the recovery tool you use when a routine change has made remote administration unavailable.

On Vozora, this means the browser console: the screen and keyboard of the server, opened from the dashboard. Vozora has no separate serial console, no VNC client access, and no rescue mode or rescue ISO. Servers have no password by default, so the browser console can only log in if you have set a password. The Linux diagnosis below applies once you are logged in.

What a serial console can recover

A serial console is most useful when Linux is running, or at least reaching a login prompt, but the network path is not usable. Common cases include an accidental ufw deny 22, a firewall reload that drops established SSH access, a malformed /etc/netplan configuration, a wrong default route, or a Docker rule that changes packet forwarding unexpectedly.

It is also useful for boot investigation. You can watch kernel and service output instead of guessing whether the VPS has frozen, is waiting for a filesystem check, or has entered emergency mode because a mounted volume is missing. On distributions configured to expose a serial getty, you should receive a normal text login prompt.

There are limits. A serial console cannot repair a filesystem that is unreadable without appropriate recovery media, and it cannot make an application healthy if the operating system itself is fine. If the kernel panics before a usable shell appears, a VNC console or rescue environment may be more appropriate because it exposes the graphical boot display and bootloader interaction.

The practical difference is simple: use serial first for command-line Linux diagnosis. Use VNC when you need to see the virtual screen, interact with GRUB, or work with an installer and rescue ISO.

Prepare before you need serial console VPS recovery

Recovery is easier when the system has been set up to be recoverable. Confirm that your image has a serial console enabled before making disruptive network changes. On many cloud images this is already configured, but do not assume it. From a working SSH session, check for a serial getty:

systemctl status serial-getty@ttyS0.service

If it is not enabled and your distribution uses ttyS0, enable it:

sudo systemctl enable --now serial-getty@ttyS0.service

The device name can differ by platform, so verify it against your VPS documentation and boot configuration. You also need a local login path. Cloud images commonly create an image user with sudo access, while direct root password login may be disabled. Know which user can log in at the console and how that user obtains root privileges.

Do not rely on an SSH key alone for console access. A browser console cannot present your local SSH agent in the same way as an SSH client. Set and securely store a strong password for a permitted local user, subject to your own access policy. If you use passwordless sudo, test it. If sudo requires a password, test that too.

The other preparation is operational rather than technical. Take a snapshot or backup before changing firewall policy, routing, boot settings or storage configuration. A console can recover a bad command; it cannot replace a restorable copy of data. Keep a record of your baseline network configuration and the last known-good firewall rules somewhere outside the VPS.

A safe recovery sequence

When SSH stops working, avoid immediately rebooting the VPS. First establish whether the fault is likely in the server, the application, or the route to it. Check the control panel status, attempt a connection from another network if possible, and verify that you are using the expected public IPv4 address and port.

Then open the serial console and log in. Start with evidence rather than edits:

ip addr show ip route show ss -ltnp | grep ':22' systemctl status ssh journalctl -b -p warning..alert

ip addr show confirms that the expected interface and address exist. ip route show reveals whether a default route remains. ss confirms whether sshd is listening, and systemctl status ssh identifies service failures. On some distributions the service is named sshd, so use the service name your image provides.

If the fault followed a firewall change, inspect the active rules before flushing anything:

sudo ufw status numbered sudo nft list ruleset

Use the tool that actually manages your firewall. Mixing UFW, raw nftables commands and Docker-managed rules without understanding their order can create a second problem while fixing the first. If UFW is responsible and port 22 should be reachable, allow it explicitly before removing broader rules:

sudo ufw allow 22/tcp sudo ufw reload

If you administer SSH on a non-standard port, use that port instead. Do not copy an allow rule for port 22 and assume it protects a service listening on 2222.

For a network configuration error, check syntax and generated state before applying another change. On a Netplan-based system:

sudo netplan generate sudo netplan try

netplan try is safer than blindly applying a remote change because it offers a rollback window. From a serial console you are less likely to lose all access mid-command, but a rollback still protects against an invalid route or interface definition. Confirm the interface name with ip link show; predictable names such as ens3 and enp1s0 are not interchangeable.

Once you believe the repair is complete, keep the serial console open and test SSH from a separate terminal. Verify both the connection and sudo access. Only then close the recovery session.

When the VPS will not boot cleanly

Boot failures need a more cautious approach. Read the console output from the beginning of the current boot where possible:

journalctl -b systemctl --failed

If the machine reaches emergency mode, log in as instructed and identify the unit or mount that failed. A common cause is an invalid /etc/fstab entry for a disk or network mount that no longer exists. Compare the file with blkid and lsblk -f before commenting out or correcting an entry.

Avoid using fsck on a mounted filesystem. If filesystem repair is required, boot into an appropriate rescue environment or attach the volume elsewhere according to your provider's recovery options. Filesystem commands can turn a recoverable configuration issue into data loss when used on the wrong device.

A failed package upgrade may leave services broken without preventing boot. Check package-manager logs and service logs, repair interrupted package configuration where appropriate, and ensure there is sufficient disk space:

df -h df -i sudo dpkg --configure -a

The last command is relevant to Debian and Ubuntu systems. It should not be treated as a universal repair command for every distribution.

Recovery mistakes that extend the outage

The most damaging pattern is changing several layers at once. Reinstalling OpenSSH, rewriting network files and flushing the firewall in one session leaves no clear cause if access returns or gets worse. Make one reversible change, test it, then continue.

Be equally careful with broad firewall flushes. Removing all rules can expose databases, container ports or administrative services to the public internet. If you must temporarily restore access, add a narrow rule for your trusted source address where your setup permits it, then rebuild the intended policy deliberately.

Do not confuse a powered-off VPS with a deleted one. Powering off may stop compute activity, but the provisioned server and its attached resources can remain billable depending on the plan. At Vozora, deleting the provisioned server stops future charges. Use power actions for maintenance and deletion only when you no longer need the machine or its data.

Make the next incident less dramatic

After recovery, write down the actual failure mode while it is fresh. Save the corrected firewall policy, keep infrastructure configuration in version control, and test network changes from a second SSH session before closing the first. For production services, add an external availability check so you know whether the fault is limited to SSH or affects the application too.

Most serial-console incidents are ordinary administration mistakes made under time pressure. A tested console login, a recent backup and a habit of making one change at a time turn them into a short repair job rather than a rebuild.

© 2026 Vozora. A trading name of Bankside Technology Ltd, registered in England and Wales, company no. 17253446. Registered office: First Floor, Swan Buildings, 20 Swan Street, Manchester, England, M4 5JW.