How can I restart the SSH daemon on Ubuntu?

When I type in service sshd restart I get a sshd: unrecognized service error.

I do have, in /etc/ssh/ a file sshd_config that I use to set config. I can also putty into the Ubuntu box (it is remote).

When I type in /etc/init.d/sshd restart I get No such file or directory

Under /usr/sbin/ there is an sshd file, but it is binary.

Is something wrong with my sshd? What do I do to fix this? To be clear, I want to be able to type service sshd restart (like all the online tutourials say) to be able to, well, restart my sshd. So that my port changes take effect.

Asked By: bharal


Ubuntu calls the service ssh, not sshd.

service ssh restart

The service is also controlled by upstart, and not sysvinit. So you’ll find it at /etc/init/ssh.conf instead of /etc/init.d/ssh.

Answered By: phemmer

Most importantly you should have permissions to do so. Most of the problem like cannot start process or cannot find some file are due to permissions. Use sudo before any command.

Now for ssh you can simply do

sudo stop ssh
sudo start ssh

This leverages upstart

Answered By: Aniket Thakur
Categories: Answers Tags: , , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.