2

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: /system.slice/ssh.service
           └─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
  • This sounds more like a rasbian issue than an Ubuntu one - does anything here help? --> Headless SSH Not Initializing Properly Jan 2, 2017 at 1:13
  • Are you ever logged in? or is it never allowing the connection? can you show verbose output of ssh? ssh -v <user>@<address>
    – j0h
    Jan 2, 2017 at 1:21
  • Noticing it says it can't find the key /etc/s... Looks to me like you need to check /etc/ssh/sshd_config and make sure you haven't accidentally messed that up, or uncommented an invalid #HostKey line.
    – earthmeLon
    Jan 2, 2017 at 2:04

3 Answers 3

2

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.

1

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
0
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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .