If you have just modified your SSH configuration file (for example, to change the default listening port or disable root login), your changes will not take effect immediately. The OpenSSH daemon reads its configuration file only when it starts up. To apply your new security settings without rebooting the entire server, you must manually restart the SSH service from the terminal.
How to Restart SSH Using Systemd
Modern Linux distributions (like Ubuntu 16.04+, Debian 8+, CentOS 7+, and Arch Linux) use systemd to manage background services. You can control the SSH daemon using the systemctl command.
- Open your terminal or connect to your server.
- Run the following command to restart the service immediately:
sudo systemctl restart ssh
(Note: On CentOS, RHEL, and Fedora, the service is named differently. Usesudo systemctl restart sshdinstead). - The command will execute silently if successful.
How to Verify the Service is Running
Because the restart command does not provide any output, it is always best practice to verify that the SSH daemon successfully turned back on and didn’t crash due to a typo in your configuration file.
- Run the following command to check the service status:
sudo systemctl status ssh - Look for the line that says Active:. It should say
active (running)in bright green text.
If the status says failed, open your /etc/ssh/sshd_config file and double-check your recent edits for syntax errors.