2

I did a fresh installation of Ubuntu Mate on my Raspberry Pi 2.

Installed openssh-server (in fact it was already installed), and changed the port to be 10022.

However, I cannot access the Pi, from the netowork, neither from the same machine (the Pi itself):

$ ping 192.168.2.130 
PING 192.168.2.130 (192.168.2.130): 56 data bytes
64 bytes from 192.168.2.130: icmp_seq=0 ttl=64 time=165.807 ms
64 bytes from 192.168.2.130: icmp_seq=1 ttl=64 time=257.509 ms
64 bytes from 192.168.2.130: icmp_seq=2 ttl=64 time=170.881 ms
64 bytes from 192.168.2.130: icmp_seq=3 ttl=64 time=1.686 ms
^C
--- 192.168.2.130 ping statistics ---
4 packets transmitted, 4 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 1.686/148.971/257.509/92.516 ms
$ ssh 192.168.2.130 -p 10022
ssh: connect to host 192.168.2.130 port 10022: Connection refused

How to solve this? Why does it appear?

On a different machine, connected on the same network and everything works fine.

  • Did you restart the SSH Daemon after changing the port? – Steve Robillard Aug 11 '19 at 11:35
  • @SteveRobillard I restarted the pi... – Ionică Bizău Aug 11 '19 at 12:07
  • What is the ouput of systemctl status ssh sshd. If it's not enabled run sudo systemctl enable --now ssh*. – jake Aug 11 '19 at 13:23
  • @jake They both are enabled but they say cannot load host key .... – Ionică Bizău Aug 11 '19 at 14:13
  • @jake That was useful to debug -- I ran sudo dpkg-reconfigure openssh-server (to regenerate the host keys) and then rebooted and it works now. I assume somehow these keys were not there after the installation. You can post an answer if you like. – Ionică Bizău Aug 11 '19 at 14:20
3

To troubleshoot your problem run systemctl status ssh. You can see from the output if the ssh server is running and enabled and also see the most recent lines from the log.

journalctl -e -u ssh.service could also be helpful to find the issue. It will show everything logged regarding the specified unit.

As we clarified in the comments you found following error cannot load host key which could be solved by regenerating the host key file: sudo dpkg-reconfigure openssh-server.

0

The SSH is not enabled in your raspberry pi. Access the root directory of SD card and create a file named “ssh” with no extension and back into you pi and reboot. This should tell you pi to enable ssh.

  • 1
    That is true for Raspbian, but is it true for Ubuntu? – Steve Robillard Aug 11 '19 at 11:36
  • Nick, I tried that, but unfortunately it does not make any change... – Ionică Bizău Aug 11 '19 at 12:07
  • 1
    This answer should be removed because it ignores the context of the question. Also, there's no such thing as "the root directory of SD card". – Dmitry Grigoryev Aug 14 '19 at 7:19
0

Sorry didn't notice that you had Ubuntu Mate on your raspberry pi. Have you tried the following commands to reinstalled openssh-server.

sudo apt-get remove openssh-server
sudo apt-get install openssh-server
# I rebooted system after install
sudo systemctl enable ssh

https://askubuntu.com/questions/921258/how-to-enable-ssh-on-boot-in-ubuntu-mate

  • Please don't make a new answer. Instead edit your first answer and correct it. – Ingo Aug 13 '19 at 7:40

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.