11

I have a machine running Ubuntu 18.04 LTS where I cannot seem to get SSH Server working.

I installed SSHServer using:

sudo apt install openssh-server

but I am getting the following when I try to start and / or check the status:

sudo systemctl start sshd

Failed to start sshd.service: Unit sshd.service not found.

.

sudo systemctl status sshd

Unit sshd.service could not be found.

I figured I must have done something wrong (typo?) when I installed, so I tried to install again thus:

sudo apt install openssh-server

to which I get:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
openssh-server is already the newest version (1:7.6p1-4ubuntu0.3).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

So, it appears it is installed, but for some reason Ubuntu cannot find it.

I am not sure where to go from here, so any suggestions would be welcome.

Thanks,

Alan.

Alan
  • 725
  • 3
  • 8
  • 17
  • I followed [this](https://help.ubuntu.com/lts/serverguide/openssh-server.html) and it worked. – TonyB Jul 28 '19 at 04:05
  • I think it is fixed by removing and reinstalling, but I have bookmarked the link to gave and will follow that next time I need to install ssh server. Thanks! – Alan Jul 28 '19 at 06:00

2 Answers2

13

It is possible that the service is not called sshd. you can try this command

systemctl -l --type service --all|grep ssh

On my ubuntu 18.04, the service is called ssh by default.

in my case, I did

sudo systemctl start ssh

If that doesn't solve your problem, you can reinstall ssh

sudo apt-get remove --purge openssh-server
sudo apt-get update
sudo apt-get install openssh-server
Nic Wanavit
  • 386
  • 3
  • 8
4
systemctl -l --type service --all|grep ssh

returned nothing at all, so I removed and re-installed as you suggested.

I also rebooted after re-installing just in case (I had rebooted before, but it did not help). It seems to be okay now. If I try that command again, I get:

ssh.service    loaded    active   running OpenBSD Secure Shell server

and if I run:

sudo systemctl status sshd

I get:

● ssh.service - OpenBSD Secure Shell server
Loaded: loaded (/lib/systemd/system/ssh.service; enabled; vendor preset: enabled)
Active: active (running) since Sun 2019-07-28 17:46:39 NZST; 1min 7s ago
Process: 1343 ExecReload=/bin/kill -HUP $MAINPID (code=exited, status=0/SUCCESS)
Process: 1337 ExecReload=/usr/sbin/sshd -t (code=exited, status=0/SUCCESS)
Process: 1151 ExecStartPre=/usr/sbin/sshd -t (code=exited, status=0/SUCCESS)
Main PID: 1166 (sshd)
Tasks: 1 (limit: 4915)
CGroup: /system.slice/ssh.service
       └─1166 /usr/sbin/sshd -D

Jul 28 17:46:37 Ubuntu-12345 systemd[1]: Starting OpenBSD Secure Shell server...
Jul 28 17:46:39 Ubuntu-12345 sshd[1166]: Server listening on 0.0.0.0 port 22.
Jul 28 17:46:39 Ubuntu-12345 systemd[1]: Started OpenBSD Secure Shell server.
Jul 28 17:46:39 Ubuntu-12345 sshd[1166]: Server listening on :: port 22.
Jul 28 17:46:45 Ubuntu-12345 systemd[1]: Reloading OpenBSD Secure Shell server.
Jul 28 17:46:45 Ubuntu-12345 sshd[1166]: Received SIGHUP; restarting.
Jul 28 17:46:45 Ubuntu-12345 systemd[1]: Reloaded OpenBSD Secure Shell server.
Jul 28 17:46:45 Ubuntu-12345 sshd[1166]: Server listening on 0.0.0.0 port 22.
Jul 28 17:46:45 Ubuntu-12345 sshd[1166]: Server listening on :: port 22.

So it looks to be okay now - at least as far as I can tell.

Thanks,

Alan.

Alan
  • 725
  • 3
  • 8
  • 17