Before You Restart Anything
If the new configuration is broken, SSH may not come back, and you cannot log in to fix it. Follow this order every time:
- Keep your current session open until a new login works.
- Test the configuration with
sudo sshd -tfirst. - Prefer a reload to a restart where a reload is enough.
- Know where the console is in your provider's control panel, in case of a lockout.
The Unit Name
| System | Unit |
|---|---|
| Ubuntu, Debian | ssh |
| AlmaLinux, Rocky Linux | sshd |
The program itself is called sshd everywhere; only the systemd unit name differs.
Step 1: Test the Configuration
sudo sshd -tNo output means the main file and the drop-ins in /etc/ssh/sshd_ are valid. An error names the file and line to fix. To see the value sshd will use for one setting, filter sshd -T:
sudo sshd -T | grep -i passwordauthenticationStep 2: Reload or Restart
# Ubuntu, Debian
sudo systemctl reload ssh
sudo systemctl restart ssh
# AlmaLinux, Rocky Linux
sudo systemctl reload sshd
sudo systemctl restart sshd- Reload: sshd rereads its configuration. Use it after changing login rules such as passwords, root login, or allowed users.
- Restart: stops and starts the service. Use it when a reload is not enough or the service is in a failed state.
Open sessions normally stay connected with either: each session runs in its own process, and the systemd units shipped by these distributions stop only the main sshd process on a restart. New logins depend on the service starting cleanly, which is why the test comes first.
Step 3: Check the Status
sudo systemctl status ssh # sshd on AlmaLinux, Rocky LinuxLook for "active (running)" and for errors in the last lines. If it failed, read the log:
sudo journalctl -u ssh -n 50 --no-pagerSocket Activation on Ubuntu
Since Ubuntu 22.10, and so on 24.04 and 26.04, systemd listens on the SSH port through ssh.socket and starts ssh.service when the first connection arrives. Debian 13 ships ssh.socket but leaves it disabled, so Debian, like AlmaLinux and Rocky Linux, runs the service directly. On Ubuntu, two things follow:
- Status can show inactive: before the first connection after boot, an inactive
ssh.servicewith an activessh.socketis normal; check both withsystemctl status ssh.socket ssh.service. - Port and address changes: a generator reads the port and listen addresses from
sshd_and its drop-ins, but only when systemd reloads its units. After changing them, runconfig sudo systemctl daemon-reloadandsudo systemctl restart ssh.socket, as described in how to change the SSH port.
Other settings are read by sshd when it starts or reloads, as on other systems. If ssh.service is not running, systemctl reload ssh fails with a message that the unit is not active; that is harmless, because the next connection starts sshd with the new configuration.
Step 4: Test from a Second Terminal
ssh user@your_server_ipOnly when this works, close the old session. If it does not, use the open session or the console to undo the last change, run sudo sshd -t, and reload again. Connection errors at this point are covered in SSH connection refused.
Rebooting the Server Instead?
A reboot is not needed for SSH changes. If you want to restart the whole machine for other reasons, see how to reboot a Linux server. To list all services and spot failed ones, see list services with systemctl.
Updated:
Linux VPS with Full Root Access
MUVCloud cloud servers run on KVM with Enterprise NVMe SSD storage and full root access, in Turkey, the Netherlands, and the USA.
More Guides
No Limits on Service or Support
You are not on your own as your projects grow. Our support engineers are ready 24/7, on several channels, whenever you need them.

- 100% customer satisfaction goal
- Our own hardware
- 24/7 ticket and email support
- 4 countries with locations