108

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.

terdon
  • 242,166
bharal
  • 1,443

2 Answers2

172

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.

phemmer
  • 71,831
3

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

  • 26
    this is really bad for remote servers, you can log yourself out with that first command and it's not automatically restarted. – therealmarv Aug 23 '16 at 21:03
  • 1
    @therealmarv reminds me of my first ip-tables remote configuration. "iptables -A INPUT -j DROP" ... then spending a while starting at a disconnected terminal wondering what happened. – Kickaha Aug 09 '17 at 13:22
  • I think it can be done in one command: sudo restart ssh. service ssh restart does not work in my Ubuntu 14.04. – chus Jul 02 '18 at 13:12