8

When you have modified /etc/ssh/sshd_config, you may execute systemctl restart sshd.service to reflect the change. At least in my environment, also, systemctl restart ssh.service works. And systemctl --all list-units ssh* tells me there isn't any service with the name sshd.service. Then why is sshd.service used wide and actually valid?

(I know the name of ssh daemon is sshd but this is not the reasonable reason, I think.)


I executed the following commands on linux mint 19 (ubuntu-base) and volumio 2 (raspbian-base), both of which are based on debian.

systemctl restart sshd.service; echo $? #=> 0
systemctl restart ssh.service; echo $? #=> 0
systemctl --no-legend --all list-units ssh* #=> only ssh.service exists
  • There is no ssh.service: Failed to restart ssh.service: Unit ssh.service not found, unless your distro symlinks it. – jasonwryan Sep 5 '18 at 5:45
  • ssh is basically termed as a client, and sshd as a server... so sshd is more reasonable – Bharat Sep 5 '18 at 5:48
  • You should state your distribution, Suse uses sshd.service. – RalfFriedl Sep 5 '18 at 5:49
  • @RalfFriedl Thank you. I added the distribution info. – ynn Sep 5 '18 at 5:57
18

The ssh service has always been named ssh in /etc/services, probably whatever the distribution, because it's the SSH protocol, not the sshd daemon.

Then it made sense, at least in the Debian implementation and thus Debian derivatives, the same name was chosen to start the service as ... service ssh start which translated into system-V style /etc/init.d/ssh.

This was kept in systemd, again for consistency since the service can be started indifferently with old style or systemd-style way. Still, an alias is also defined for compatibility with other distributions which made a different choice:

[Install]
WantedBy=multi-user.target
Alias=sshd.service

So both can be used on Debian and derivatives and they represent the same service.

  • Thank you. Now I understand the structure. As you say, I could find the alias declaration in /lib/systemd/system/ssh.service. – ynn Sep 5 '18 at 6:31
6

As already established, different names are used in different distributions.

There are valid reasons for both

  • The server is called sshd, therefor sshd.service
  • sshd means "SSH Daemon" or "SSH Server", so "SSH Server Service" would be double.

So it would be a matter of preference of the distro maintainers. These preferences may also change over time, I remember a time when Suse switched from ntp to ntpd for the service name.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.