0

I can't get SSH to work on my newly setup Raspberry Pi 3. Installed a fresh image of Raspbian Stretch Lite.

I am unable to access the machine in the LAN using SSH:

pi@domoticz_pi:~ $ ssh 192.168.178.123
Connection reset by 192.168.178.123 port 22

The Pi can be pinged succesfully.

Tried the following to get it to work, without any result:

  • Put a empty file called "ssh" (without extension) in the boot partition, using a windows machine (the machine I used to write the image to the SD)
  • Enable SSH with the GUI many times. sudo raspi-config. "Interfacing Options" -> "SSH"
  • Write ssh file to the /boot directory. cd /boot && sudo touch ssh. Reboot the Pi.
  • Restarted the service multiple times: sudo systemctl restart ssh

I don't have a clue why this is not working. Any ideas?

  • 1
    What result do you get if you run on the RPi sudo systemctl status ssh? – Fabian May 10 '18 at 7:46
  • Please edit your question and give us the output from ssh -vvv pi@192.168.178.123. – Ingo May 10 '18 at 9:42
  • @Fabian, sudo systemctl status ssh gave me pointers to the cause of the problem. See my answer. – Bram Gerritsen May 11 '18 at 6:32
  • Please add the error messages Could not load host key and key_load_public: invalid format to your question, they are really important and will help other people to find this page in the future. Glad to hear it's solved! – Fabian May 11 '18 at 10:16
  • 1
    So there was a residual key? – Andy Anderson May 11 '18 at 17:03
3

I have found the solution. See this blog post.

sudo rm /etc/ssh/ssh_host_* && sudo dpkg-reconfigure openssh-server

1

You normally start ssh with user@host - on Raspbian pi is the normal user.

Try ssh -vvv pi@host for more diagnostics

  • Yes I know, but get the same error. Thanks anyway. – Bram Gerritsen May 10 '18 at 6:37
  • @Fabian exactly the UID must be the same. You can have same name with different UID. – Ingo May 10 '18 at 9:36
  • @Fabian if you want to chat with Ingo about his irrelevant comment do it in chat. – Milliways May 12 '18 at 9:17
0

You can also try the below if sudo rm /etc/ssh/ssh_host_* && sudo dpkg-reconfigure openssh-server did not work.

$ sudo su  
# vi /etc/hosts.allow  
sshd:ALL  
$ sudo service ssh restart  
  • 1
    Do you have a reason why you think this might help? – RalfFriedl Mar 11 at 7:10

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.