2

I know this has been asked several times, but I went through a lot of trying to connect from my PC to my Raspberry Pi via SSH and I don't get it to work.

My Setup:

  • Raspberry Pi 3 Model B+
  • Working RetroPie 4.4 installation
  • Windows-PC with Putty

What I want to do:

  • Connect with Putty to my raspberry Pi over SSH
  • Preferrably over wlan, but I tried both cabled and wlan

What I tried/did:

  • Tried to connect with Putty (wlan) --> I got a connection refused error
  • Enabled SSH with the raspi-config tool
  • Tried to connect with Putty again -->
  • putty error messages
  • Tried to ping the wlan-ip: success
  • Tried to open a telnet session on port 22: success
  • Tried tcpping on port 22: success
  • Despite that: still the same error.
  • Connected PC over a simple switch to the pi.
  • Tried all of the above with the eth0 ip with same result as wlan.

I think I can be fairly sure that the SSH server is listening (ps -ef says so, too) and a connection could be established. I do not think it is a problem of putty as i see tons of people using it with their raspberrys. I do not think it is a wlan related problem as I get the same results on the wired connection.

Could anyone point me in a direction where the error might be located?

Thank a lot.

  • Look at the server logs. It seems the connection is accepted and later terminated. The logs should state why that happens. – RalfFriedl Aug 19 '18 at 12:37
  • Thanks @RalfFriedl ! I checked the logs and found a solution. See my answer post. – user2614898 Aug 19 '18 at 14:11
2

So I checked the server logs and found the following error multiple times:

Aug 19 11:52:44 retropie sshd[9707]: error: key_load_public: invalid format
Aug 19 11:52:44 retropie sshd[9707]: error: Could not load host key: /etc/ssh/ssh_host_rsa_key

I deleted the keys and reconfigured them:

sudo rm /etc/ssh/ssh_host*
sudo dpkg-reconfigure openssh-server

After a restart, the connection worked like a charm.

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.