Keys, no root login and a second session open while you test: the order of operations matters more than the settings.

Most SSH hardening advice is correct and most outages from it are self-inflicted. The settings are simple; applying them safely is the skill.

Before you change anything

Open a second session and leave it connected. Confirm that key-based login works for your account in a third attempt. Only then change the server configuration.

The usual changes

  • Allow key-based authentication and disable password login.
  • Disable direct root login and use an unprivileged account with sudo.
  • Limit which users and groups may connect.

Test the configuration, then reload

Run the daemon’s configuration check before reloading. A reload keeps existing sessions alive, so your second session is a safety net if the new settings are wrong.

I. Varga

Staff writer (sample byline). Sample author used while the editorial team is being set up. Replace with the real byline.