↑ ↓ select, Enter open, Esc close

Test the sshd config and reload the SSH service

Caution: This command changes the system. Understand what it does before you run it.

root@server
sshd -t && systemctl reload ssh

sshd -t checks the configuration, including included files from /etc/ssh/sshd_config.d/, and prints the offending line on errors. The service is only reloaded if the test succeeds. Existing sessions are kept.

Note: Keep the current session open and test the login in a second terminal. On Ubuntu 24.04, SSH is started via ssh.socket, so a port change there also requires systemctl daemon-reload and systemctl restart ssh.socket.

Also searched as

  • test sshd config before restart
  • sshd -t syntax check
  • reload ssh without losing connection

Related one-liners

All in SSH

Read first, then run.

The commands on myline.de act directly on servers, files and databases. A wrong path or placeholder can delete data irreversibly or make a server unreachable.

  • All commands are provided without warranty and are not tested on every system.
  • Understand what a command does before running it, and check every placeholder.
  • Make a backup first and, if possible, try it on a test system.
  • You run commands at your own risk. Liability for damages is excluded to the extent permitted by law.