10

I have installed Ubuntu Mate 16.04.2 LTS on my Pi2 and installed OpenSSH but when the Pi starts/restarts SSH does not automatically turn on.

I've tried sudo systemct1 enable ssh but all I get is "Command not found"

I am connecting via wifi from my windows PC, if I enable the service manually I am able to connect without issue, I just can't get it to enable SSH on boot.

I am a newer user so if this is a multi-step process I would appreciate a step by step answer, thank you.

  • 2
    There too many answer below, but nobody have described that your command was wrong - it should has lowercase L, not 1. The correct command is sudo systemctl enable ssh (not sudo systemct1 enable ssh). – N0rbert Jul 31 '19 at 10:14
15

I think the command you're looking for is:

sudo systemctl enable ssh

(Note the letter "l" at the end of systemctl, rather than the number "1" at the end of systemct1 as you currently have it in the question.)

  • 1
    Also, if it does not work, try sudo systemctl disable ssh.socket, because even after I enabled ssh, it did not autorun (systemctl is-enabled ssh was enabled, but systemctl is-active ssh was inactive) until I manually sudo systemctl start ssh. But then I noticed that ssh.socket was activated on boot, so I disabled it, and by doing it, ssh autoruned. – AlexP Jul 18 '17 at 17:59
8

To enable SSH server, you can try opening up a terminal window and typing the following command:

sudo service ssh enable

and then SSH server should be enabled on restart.

  • Do not recommend using service instead of systemctl. This option applies only to systems with systemd. – Jakuje Jun 2 '17 at 6:10
  • Yup, you're right, and I do think that sempaiscuba does provide a better answer than mine. – Ken Jun 2 '17 at 9:07
  • 1
    Correcting your question means changing it to the same what is already in the other upvoted question. Yes, Ubuntu 16 comes with systemd and you recommend using the old-school service. – Jakuje Jun 2 '17 at 9:10
7

I experienced a problem when commands from this topic wouldn't help. I am on Mate 18.04 and I got ssh to work only after I reinstalled openssh-server and run command from topic. So if you experience the same problem, just:

sudo apt-get remove openssh-server
sudo apt-get install openssh-server
# I rebooted system after install
sudo systemctl enable ssh
  • 1
    You my friend just made my day! Thank you so much – zwolin Aug 2 '19 at 15:44
  • This also worked for me on a Ubuntu Mate install on a Raspberry Pi. Apparently openssh-server is installed by default but no keys are generated so it won't work. Removing and reinstalling generates the necessary keys. – UbuntuUser Jan 4 '20 at 20:14
3

Try running these 2 commands which should enable ssh:

sudo systemctl enable ssh
sudo service ssh restart
0

This worked for me

sudo dpkg-reconfigure openssh-server

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.