7

I just installed Ubuntu Server 16.04 on a virtual machine and then installed openssh-server. When I tried to enable sshd:

systemctl enable sshd.service

I got this message:

Failed to execute operation: Too many levels of symbolic links

Does anyone know what this is? Did I forget to do something?

Deltik
  • 19,353
  • 17
  • 73
  • 114
SadSeven
  • 185
  • 1
  • 1
  • 5

1 Answers1

12

That's because the service name is actually ssh.service, not sshd.service.

Do this instead:

systemctl enable ssh.service

Explanation

When you install openssh-server, the service is automatically enabled in systemd. During the enabling process, a symbolic link for an enabled sshd.service is also created. This symbolic link goes away if you do systemctl disable ssh.service or systemctl disable sshd.service.

You can see the symbolic link is reportedly created here:

root@node51 [~]# systemctl enable ssh.service
Synchronizing state of ssh.service with SysV init with /lib/systemd/systemd-sysv-install...
Executing /lib/systemd/systemd-sysv-install enable ssh
Created symlink from /etc/systemd/system/sshd.service to /lib/systemd/system/ssh.service.

Because of systemd's design, systemd will not enable a service that is a symbolic link.
This is discussed on Red Hat Bugzilla.

Deltik
  • 19,353
  • 17
  • 73
  • 114
  • It seems to work but I don't get the explanation, sorry. You're telling me that the service file is called "ssh.service" on ubuntu but the config file is "sshd.service"? – SadSeven Apr 25 '16 at 18:27
  • @SadSeven: When `ssh.service` is enabled, it creates `sshd.service` kind of as an alias. – Deltik Apr 25 '16 at 18:28
  • Hmm, but how does that explain that error? "Failed to execute operation: Too many levels on symbolic links" – SadSeven Apr 25 '16 at 18:29
  • 2
    @SadSeven: `/etc/systemd/system/sshd.service` is a symbolic link. SystemD won't enable a service that is a symbolic link. [Discussion here.](https://bugzilla.redhat.com/show_bug.cgi?id=955379) – Deltik Apr 25 '16 at 18:37