36

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
  • 999
  • I followed this and it worked. – TonyB Jul 28 '19 at 04:05
  • 1
    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
  • even after the sshd purge and reinstall.. no luck bringing sshd service back up. I just reinstalled Ubuntu (the fastest option). sshd stop working because i removed the /home disk drive in a VM, when it was originally installed with. If you cant reinstall, Maybe you need to copy your old /home contents or tweak your /etc/fstab add or revert back the original /home mount path that you installed with? – Carson Nov 17 '24 at 03:59

2 Answers2

46

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
  • 746
  • 7
  • 9
  • 3
    This helped me on my Ubuntu 24.04 in July 2024. It's funny because Ubuntu documentation has this instruction: "Then, restart the sshd server application to effect the changes using the following command sudo systemctl restart sshd.service " – Dr Phil Jul 17 '24 at 13:49
  • Kubuntu 24.04 and same situation for me. Thanks for the help, Nic. – zjdrummond Aug 04 '24 at 20:34
  • @DrPhil the latest documentation is correct. Still, I don't know why they don't redirect, instead of just mentioning the new URL at the top of the outdated page. In my 24.04, I had to remove cloud-init (as I didn't need it) in order to remove sshd as an option when systemctl autocompletes in bash – Kamal Jan 26 '25 at 20:39
  • I've asked the documentation team to redirect the old docs to the new ones: https://discourse.ubuntu.com/t/redirect-outdated-server-docs-to-new-location/54094 – Kamal Jan 27 '25 at 15:55
2

This solved issue in my case.

sudo apt-get install openssh-server

sudo systemctl enable ssh

sudo systemctl start ssh

Check also: https://www.cyberciti.biz/faq/ubuntu-linux-install-openssh-server/

luka
  • 21