Plateo
Posts: 6
Joined: Sat Jan 28, 2017 7:10 pm

Unable to SSH (even if activated)

Sat Jan 28, 2017 7:59 pm

Hi there,

I've been a Rasp 3 owner for a few months.
I've been used to comunicate with my Pi by SSH (using Putty), and it was working fine.

Recently, I re-installed raspbian with the latest version available. Since SSH isn't activated by default on Raspbian, I activated it through raspi-config

The thing is : now, I can't connect with SSH at all. Every time I try to connect from Putty or FileZilla, I get a message "Network Error : software caused connection abord".
I've made no changes to my installation (my raspberry has fixed IP and is connected to my router by Ethernet) except installing the new Raspbian, and I've been trying to fix my problem since 2 days, with no success !

Here is what I get when I use sudo systemctl status ssh.service

Code: Select all

sudo systemctl status ssh.service
● ssh.service - OpenBSD Secure Shell server
   Loaded: loaded (/lib/systemd/system/ssh.service; enabled)
   Active: active (running) since Sat 2017-01-28 19:01:35 UTC; 50min ago
 Main PID: 519 (sshd)
   CGroup: /system.slice/ssh.service
           └─519 /usr/sbin/sshd -D

Jan 28 19:39:42 raspberrypi sshd[2392]: error: key_load_public: invalid format
Jan 28 19:39:42 raspberrypi sshd[2392]: error: Could not load host key: /etc/ssh/ssh_host_ed25519_key
Jan 28 19:58:35 raspberrypi sshd[2770]: error: key_load_public: invalid format
Jan 28 19:58:35 raspberrypi sshd[2770]: error: Could not load host key: /etc/ssh/ssh_host_rsa_key
Jan 28 19:58:35 raspberrypi sshd[2770]: error: key_load_public: invalid format
Jan 28 19:58:35 raspberrypi sshd[2770]: error: Could not load host key: /etc/ssh/ssh_host_dsa_key
Jan 28 19:58:35 raspberrypi sshd[2770]: error: key_load_public: invalid format
Jan 28 19:58:35 raspberrypi sshd[2770]: error: Could not load host key: /etc/ssh/ssh_host_ecdsa_key
Jan 28 19:58:35 raspberrypi sshd[2770]: error: key_load_public: invalid format
Jan 28 19:58:35 raspberrypi sshd[2770]: error: Could not load host key: /etc/ssh/ssh_host_ed25519_key

I've got lots of red-coloured errors when using this command so there's a real problem whith my Pi's SSH. And even if I do a clean install, I still get the same problem !

Any ideas ?

EDIT : OK so here are some additional notes.
I can PING my Pi with no problem ... And I can even use VNC to get distant desktop access (VNC is working perfectly) ! But I absolutly need SSH.

User avatar
FTrevorGowen
Forum Moderator
Forum Moderator
Posts: 5554
Joined: Mon Mar 04, 2013 6:12 pm
Location: Bristol, U.K.
Contact: Website

Re: Unable to SSH (even if activated)

Sat Jan 28, 2017 8:31 pm

Ok, you say you activated the SSH server (what method?). Did you also change the password for user pi (IIRC I think that's also needed, depending on how you intend to authenticate your login)
Trev.
Still running Raspbian Jessie or Stretch on some older Pi's (an A, B1, 2xB2, B+, P2B, 3xP0, P0W, 2xP3A+, P3B+, P3B, B+, and a A+) but Buster on the P4B's. See: https://www.cpmspectrepi.uk/raspberry_pi/raspiidx.htm

Plateo
Posts: 6
Joined: Sat Jan 28, 2017 7:10 pm

Re: Unable to SSH (even if activated)

Sat Jan 28, 2017 8:34 pm

Hi.
I activated SSH using the raspi-config command. It is clearly delcared as being activated in the system's properties.
The password is still the default one. Does it really has an incidence ?

User avatar
FTrevorGowen
Forum Moderator
Forum Moderator
Posts: 5554
Joined: Mon Mar 04, 2013 6:12 pm
Location: Bristol, U.K.
Contact: Website

Re: Unable to SSH (even if activated)

Sat Jan 28, 2017 8:42 pm

Plateo wrote:Hi.
I activated SSH using the raspi-config command. It is clearly delcared as being activated in the system's properties.
The password is still the default one. Does it really has an incidence ?
Try changing it (I always do so as it's "good practice" even though my Pi's are only "locally" visible). IIRC, it was the other aspect of the "security changes" made in November 2016:
https://www.raspberrypi.org/blog/a-secu ... ian-pixel/
Trev.
Still running Raspbian Jessie or Stretch on some older Pi's (an A, B1, 2xB2, B+, P2B, 3xP0, P0W, 2xP3A+, P3B+, P3B, B+, and a A+) but Buster on the P4B's. See: https://www.cpmspectrepi.uk/raspberry_pi/raspiidx.htm

Plateo
Posts: 6
Joined: Sat Jan 28, 2017 7:10 pm

Re: Unable to SSH (even if activated)

Sat Jan 28, 2017 8:58 pm

At first, thanks for the help !

So I tried to connect with SSH after changing password for user pi.
The problem is still here, nothing changed

DirkS
Posts: 10315
Joined: Tue Jun 19, 2012 9:46 pm
Location: Essex, UK

Re: Unable to SSH (even if activated)

Sat Jan 28, 2017 9:59 pm

Code: Select all

Jan 28 19:39:42 raspberrypi sshd[2392]: error: key_load_public: invalid format
Jan 28 19:39:42 raspberrypi sshd[2392]: error: Could not load host key: /etc/ssh/ssh_host_ed25519_key
Jan 28 19:58:35 raspberrypi sshd[2770]: error: key_load_public: invalid format
Jan 28 19:58:35 raspberrypi sshd[2770]: error: Could not load host key: /etc/ssh/ssh_host_rsa_key
Jan 28 19:58:35 raspberrypi sshd[2770]: error: key_load_public: invalid format
Jan 28 19:58:35 raspberrypi sshd[2770]: error: Could not load host key: /etc/ssh/ssh_host_dsa_key
Jan 28 19:58:35 raspberrypi sshd[2770]: error: key_load_public: invalid format
Jan 28 19:58:35 raspberrypi sshd[2770]: error: Could not load host key: /etc/ssh/ssh_host_ecdsa_key
Jan 28 19:58:35 raspberrypi sshd[2770]: error: key_load_public: invalid format
Jan 28 19:58:35 raspberrypi sshd[2770]: error: Could not load host key: /etc/ssh/ssh_host_ed25519_key
Looking at these messages I would say you have a problem with the host keys.
Do these files (/etc/ssh/ssh_host_*) actually exist?
Maybe they are thrashed?
Maybe you can regenerate them:

Code: Select all

sudo rm /etc/ssh/ssh_host*
sudo dpkg-reconfigure openssh-server
and then restart the ssh server (or reboot)

Plateo
Posts: 6
Joined: Sat Jan 28, 2017 7:10 pm

Re: Unable to SSH (even if activated)

Sat Jan 28, 2017 10:31 pm

DirkS wrote:

Code: Select all

Jan 28 19:39:42 raspberrypi sshd[2392]: error: key_load_public: invalid format
Jan 28 19:39:42 raspberrypi sshd[2392]: error: Could not load host key: /etc/ssh/ssh_host_ed25519_key
Jan 28 19:58:35 raspberrypi sshd[2770]: error: key_load_public: invalid format
Jan 28 19:58:35 raspberrypi sshd[2770]: error: Could not load host key: /etc/ssh/ssh_host_rsa_key
Jan 28 19:58:35 raspberrypi sshd[2770]: error: key_load_public: invalid format
Jan 28 19:58:35 raspberrypi sshd[2770]: error: Could not load host key: /etc/ssh/ssh_host_dsa_key
Jan 28 19:58:35 raspberrypi sshd[2770]: error: key_load_public: invalid format
Jan 28 19:58:35 raspberrypi sshd[2770]: error: Could not load host key: /etc/ssh/ssh_host_ecdsa_key
Jan 28 19:58:35 raspberrypi sshd[2770]: error: key_load_public: invalid format
Jan 28 19:58:35 raspberrypi sshd[2770]: error: Could not load host key: /etc/ssh/ssh_host_ed25519_key
Looking at these messages I would say you have a problem with the host keys.
Do these files (/etc/ssh/ssh_host_*) actually exist?
Maybe they are thrashed?
Maybe you can regenerate them:

Code: Select all

sudo rm /etc/ssh/ssh_host*
sudo dpkg-reconfigure openssh-server
and then restart the ssh server (or reboot)
And my problem is solved !
Those file were there, but they were in fact corrupt ! I deleted and regenerate them, and now I can access my SSH network ! Many thanks !

DirkS
Posts: 10315
Joined: Tue Jun 19, 2012 9:46 pm
Location: Essex, UK

Re: Unable to SSH (even if activated)

Sat Jan 28, 2017 11:06 pm

Good to hear that you got the problem solved.

It's a bit worrying that these files are corrupted on a new install. I hope that they are the only corrupted files...

ArcAiN6
Posts: 9
Joined: Sat Apr 02, 2016 12:42 am

Re: Unable to SSH (even if activated)

Sun Jan 29, 2017 5:46 pm

I'm really beginning to hate this little device... Just installed latest raspbian on a pi2 model b, added the ssh file to the boot folder, booted in, and I can ping it, and ger replies... it can also connect to the internet over ethernet... However, i can't connect via SSH.

I would change from the default password, but i can't friggin SSH in to do it. I have no keyboard on it, because my wireless keyboard won't work with it..

I'm about at my wits end... I've been using several pi's for quite some time, and now that i've upgraded to the latest raspbian, i can't seem to get anything to work right.

DirkS
Posts: 10315
Joined: Tue Jun 19, 2012 9:46 pm
Location: Essex, UK

Re: Unable to SSH (even if activated)

Sun Jan 29, 2017 9:53 pm

ArcAiN6 wrote:I'm really beginning to hate this little device... Just installed latest raspbian on a pi2 model b, added the ssh file to the boot folder, booted in, and I can ping it, and ger replies... it can also connect to the internet over ethernet... However, i can't connect via SSH.
How did you create the ssh file? If you did it on a Windows machine extensions for known files is hidden then you may have created 'ssh.txt'.
AFAIK that will not trigger ssh activation (at least, not until a fix for that has been added to the downloadable Raspbian images).

BTW: how do you know you can reach the Internet? Did you use a mouse for that? If that's the case then you can activate ssh with the RPF configuration utility...

ArcAiN6
Posts: 9
Joined: Sat Apr 02, 2016 12:42 am

Re: Unable to SSH (even if activated)

Sun Jan 29, 2017 11:39 pm

created the ssh file on a nix machine, and yes, i checked to make sure SSH was enabled using the touchscreen on the pi, I'm going to see if i still have a copy of an older version of raspbian, because it didn't start showing up until this version. I have a sneaking suspicion that perhaps they are trying to enforce the password change, which isn't bad in itself, except in situations where people need to ssh in to install matchbox-keyboard, and the touch screen calibration stuff.

ArcAiN6
Posts: 9
Joined: Sat Apr 02, 2016 12:42 am

Re: Unable to SSH (even if activated)

Mon Jan 30, 2017 12:24 am

well.. i finally managed to get in via a VNC client ,Had to download and use realvnc, i prefer tightvnc, but evidently, it doesn't support the encryption methods being used.

Anywho, once i was able to VNC in, i had to regenerate the keys as outlined in earlier posts, that got rid of the errors.. and i was then able to ssh in.

Now, because i've run into this on EVERY pi i have, it seems it may not be the fault of the user, but an issue with the image, because i've downloaded the image twice, and written it to two different cards, and plugged one into a pi zero, and one into a pi 2, and they both had the exact same issue, and the exact same fix.

Not sure what's going on with the latest raspbian image, but i've been having nothing but issues with it.. on the plus side, i no longer need to use those janky waveshare drivers :D

Rasilon
Posts: 101
Joined: Wed Mar 11, 2015 7:30 pm

Re: Unable to SSH (even if activated)

Thu Jan 04, 2018 7:53 pm

oh thank you, this has been driving me nuts. hope this fix is a sticky.

drgeoff
Posts: 10538
Joined: Wed Jan 25, 2012 6:39 pm

Re: Unable to SSH (even if activated)

Thu Jan 04, 2018 11:26 pm

Those keys and files take some time to be generated when the system is first booted. Could it have been rebooted or shutdown before they were finalised?

welaing
Posts: 2
Joined: Mon Nov 27, 2017 7:30 pm

Re: Unable to SSH (even if activated)

Thu Nov 14, 2019 9:53 pm

DirkS wrote:
Sat Jan 28, 2017 9:59 pm

Code: Select all

Jan 28 19:39:42 raspberrypi sshd[2392]: error: key_load_public: invalid format
Jan 28 19:39:42 raspberrypi sshd[2392]: error: Could not load host key: /etc/ssh/ssh_host_ed25519_key
Jan 28 19:58:35 raspberrypi sshd[2770]: error: key_load_public: invalid format
Jan 28 19:58:35 raspberrypi sshd[2770]: error: Could not load host key: /etc/ssh/ssh_host_rsa_key
Jan 28 19:58:35 raspberrypi sshd[2770]: error: key_load_public: invalid format
Jan 28 19:58:35 raspberrypi sshd[2770]: error: Could not load host key: /etc/ssh/ssh_host_dsa_key
Jan 28 19:58:35 raspberrypi sshd[2770]: error: key_load_public: invalid format
Jan 28 19:58:35 raspberrypi sshd[2770]: error: Could not load host key: /etc/ssh/ssh_host_ecdsa_key
Jan 28 19:58:35 raspberrypi sshd[2770]: error: key_load_public: invalid format
Jan 28 19:58:35 raspberrypi sshd[2770]: error: Could not load host key: /etc/ssh/ssh_host_ed25519_key
Looking at these messages I would say you have a problem with the host keys.
Do these files (/etc/ssh/ssh_host_*) actually exist?
Maybe they are thrashed?
Maybe you can regenerate them:

Code: Select all

sudo rm /etc/ssh/ssh_host*
sudo dpkg-reconfigure openssh-server
and then restart the ssh server (or reboot)

Thank you, DirkS - regenerating the host key files worked. Thank you very much!

Best,
William

Return to “Troubleshooting”