SSH issue on Ubuntu Mate / Raspberry PI

I keep have an issue with SSH

I always have this message when trying to connect :

Connection closed by 192.168.1.10 port 22

When I check the SSH status

 ssh.service - OpenBSD Secure Shell server Loaded: loaded (/lib/systemd/system/ssh.service; enabled; vendor preset: enab Active: active (running) since Sun 2017-01-01 23:17:08 GMT; 57min ago Process: 804 ExecReload=/bin/kill -HUP $MAINPID (code=exited, status=0/SUCCESS Main PID: 487 (sshd) CGroup: / └─487 /usr/sbin/sshd -D
Jan 01 23:17:14 kevin-desktop sshd[487]: Server listening on :: port
22. Jan 02 00:14:09 kevin-desktop sshd[2078]: error: key_load_public: invalid format Jan 02 00:14:09 kevin-desktop sshd[2078]: error: Could not load host key: /etc/s Jan 02 00:14:09 kevin-desktop sshd[2078]: error: key_load_public: invalid format Jan 02 00:14:09 kevin-desktop sshd[2078]: error: Could not load host key: /etc/s Jan 02 00:14:09 kevin-desktop sshd[2078]: error: key_load_public: invalid format Jan 02 00:14:09 kevin-desktop sshd[2078]: error: Could not load host key: /etc/s Jan 02 00:14:09 kevin-desktop sshd[2078]: error: key_load_public: invalid format Jan 02 00:14:09 kevin-desktop sshd[2078]: error: Could not load host key: /etc/s Jan 02 00:14:09 kevin-desktop sshd[2078]: fatal: No supported key exchange algor
3

3 Answers

I've seen this myself, it's when the host keys get corrupted. You can reset them by doing:

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

I'm yet to figure out why they got corrupted.

Generate a new set of keys with this on the client:

ssh-keygen

Take the contents of the public key from the client:

~/.ssh/id_rsa.pub

And append them to the authorized keys file on the server:

~/.ssh/authorized_keys

Permissions should look like this on the server:

-rw------- 1 user1 user1 399 Apr 20 09:04 authorized_keys
drwx------ 2 user1 user1 4096 Apr 20 09:04 .ssh
fatal: No supported key exchange algor...

Looks like the algorithms supported by your client differ from the ones supported by the server. Set up LogLevel DEBUG in server /etc/ssh/sshd_config and use ssh -vvv to get more information why it fails.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like