0

I am having difficulty disabling sshd. [I want it to be available but not autorun]

I followed How to disable autostart of SSHD in Ubuntu 15.04 but to no avail:

$ ps -ef|grep sshd
root       742     1  0 11:43 ?        00:00:00 /usr/sbin/sshd -D

ie it is still running. And yet

$ systemctl status sshd
● sshd.service - OpenBSD Secure Shell server
Loaded: loaded (/etc/systemd/system/sshd.service; disabled; vendor preset: enabled)
Active: inactive (dead)

IOW ps shows its active while systemctl shows not

Rusi
  • 183

2 Answers2

1

You are being led up the garden path by a service unit file created by the local administrator in /etc/systemd/system/sshd.service. That is not the Ubuntu version 15 packaged service unit.

There are three of the latter, and they live at:

  • /lib/systemd/system/ssh.socket — socket unit for the SSH socket when systemd is doing the listening for connections
  • /lib/systemd/system/ssh@.service — template service unit, instantiated by connections made to the SSH socket when systemd is doing the listening
  • /lib/systemd/system/ssh.service — service unit for when OpenSSH is doing the listening for connections

As noted in comments to answers in the original question, the name of the SSH service on Ubuntu Linux and Debian Linux is ssh not sshd.

Further reading

JdeBP
  • 3,959
  • Ok so I undid that earlier step and (re-)softlinked /etc/systemd/system/sshd.service to /lib/systemd/system/ssh.service. Now what? – Rusi Dec 30 '15 at 11:02
  • Ok. After that doing a disable of ssh.service seems to have worked. Just put in that line and I'll accept your answer (and delete these comments) -- thanks – Rusi Dec 30 '15 at 11:06
  • Well since there is no more activity here, I'll put my caveats and accept. The earlier linked thread to change sshD.service is probably bad advice. Dont do it or if done undo it. Thereafter just disable ssh (not sshd) – Rusi Jan 01 '16 at 03:13
0

use this

systemctl disable ssh.socket
Avicii
  • 1