Test the sshd config and reload the SSH service
test sshd config before restart | sshd -t syntax check | reload ssh without losing connection | sshd | systemctl | configurationCaution: This command changes the system. Understand what it does before you run it.
sshd -t && systemctl reload sshsshd -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