SSH Recovery
Prepare a recovery path and troubleshoot SSH server configuration.
Before you run
Before changes, keep a working session and independent provider console or physical access. Back up the complete relevant configuration, including included files and access-control rules, in a protected location and test your recovery procedure. Do not copy private keys or OTP secrets into public backups. Service and log names vary by distribution.
Server-side steps use Ubuntu as an example. Commands, configuration paths and service names may differ on other systems. Run client-side steps on the client as indicated.
After applying changes, verify that you can sign in and that the intended behavior works in a new SSH session. Keep the current session open until verification succeeds, so you can restore the configuration if necessary.
Examples
From the existing session or console, validate syntax and inspect effective settings. Use sshd -T -C for relevant Match rules.
sudo sshd -t
sudo sshd -TOn Ubuntu with the ssh service, inspect service status and recent logs; use your distribution’s service name where different.
sudo journalctl -u ssh -n 100 --no-pager
sudo systemctl status ssh --no-pagerFrom the console, edit the appropriate configuration file and restore only the affected settings. Validate and reload; test a separate login before closing the working session.
sudoedit /etc/ssh/sshd_config
sudo sshd -t && sudo systemctl reload sshAuthoritative references
Reviewed October 27, 2026