I keep have an issue with SSH
I always have this message when trying to connect :
Connection closed by 192.168.1.10 port 22When 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-keygenTake the contents of the public key from the client:
~/.ssh/id_rsa.pubAnd append them to the authorized keys file on the server:
~/.ssh/authorized_keysPermissions 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.