Ubuntu – How to restart the SSH service


How do I stop/start ssh? I've tried

/etc/init.d/ssh restart
sudo service ssh restart
sudo restart ssh

I get errors every time.

Best Answer

15.04 and newer:

Use this command:

sudo systemctl restart ssh

To restart the SSH server/daemon.

Going forward with systemd starting with Ubuntu 15.04, you now use this syntax to stop, start, or restart services:

sudo systemctl <action> <service-name>