I changed the configuration in:
/etc/ssh/sshd_configbut the changes were only applied after rebooting the server. How to apply changes without a reboot?
16 Answers
Simply restart the sshd service:
sudo service sshd restartor:
sudo /etc/init.d/sshd restartJust in case you are restarting remotely, the configuration should be checked first to make sure it will not fail to start:
sudo sshd -t 5 There's an even less intrusive way to do this, without restarting the SSH service.
From man sshd:
sshd rereads its configuration file when it receives a hangup signal, SIGHUP, by executing itself with the name and options it was started with, e.g. /usr/sbin/sshd.
So you can use a command like the following to send SIGHUP to the SSH server process:
sudo kill -SIGHUP $(pgrep -f "sshd -D")The pgrep -f "sshd -D" part will return only the PID of the sshd daemon process that listens for new connections, since there are likely to be other PIDs for each active session that don't need the signal.
For Systemd Systems (Ubuntu default)
sudo systemctl reload sshd.serviceor
sudo systemctl reload sshdor
sudo /bin/systemctl reload sshd.serviceFor Sysvinit / Systemd (Linux from Scratch default and Unix systems)
sudo service sshd reloador
sudo /etc/init.d/sshd reloadUbuntu uses systemd: Here the service command passes the units: start, stop, status, and reload through to their systemctl/initctl equivalents.
sudo service ssh restartwill not do it. You need to restart sshd, not ssh:
sudo service sshd restart 1 As root check
service --status-all | grep sshI had no sshd service, but had ssh service on Ubuntu server. Then
service ssh restart Reload may be a better alternative to restart
sudo service sshd reloadunder the hood it sends HUP signal to sshd daemon process almost the same way Steven K already answered. The difference is that this variant uses killproc function instead of kill command directly in order to send the signal in even more precise way (to reduce possible errors of sending signals to wrong processes).
The configuration is reread without restarting/stopping the service.
Of course it worth to find out how exactly SSH deamon is called actually as others discussed.