sshd shuts down with "No supported key exchange algorithms" error

I ran into this problem on Fedora. Eventually I noticed:

root@wisdom:/etc/ssh# ll
total 268K
drwxr-xr-x.   2 root root     4.0K Jun 30 06:06 ./
drwxr-xr-x. 128 root root      12K Jun 30 05:15 ../
-rw-r--r--.   1 root root     237K Jun  8 23:30 moduli
-rw-r--r--.   1 root root     2.2K Jun  8 23:30 ssh_config
-rw-------.   1 root root     4.3K Jun 30 06:03 sshd_config
-rw-r-----.   1 root ssh_keys    0 Jun 27 00:46 ssh_host_ecdsa_key
-rw-r--r--.   1 root root        0 Jun 27 00:46 ssh_host_ecdsa_key.pub
-rw-r-----.   1 root ssh_keys    0 Jun 27 00:46 ssh_host_ed25519_key
-rw-r--r--.   1 root root        0 Jun 27 00:46 ssh_host_ed25519_key.pub
-rw-r-----.   1 root ssh_keys    0 Jun 27 00:46 ssh_host_rsa_key
-rw-r--r--.   1 root root        0 Jun 27 00:46 ssh_host_rsa_key.pub

The key files are zero length! I generated new key pairs and it fixed the problem:

ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key
ssh-keygen -t ecdsa -f /etc/ssh/ssh_host_ecdsa_key
ssh-keygen -t ed25519 -f /etc/ssh/ssh_host_ed25519_key

I just hit the same issue, solved it by turning my relative HostKey path into an absolute one, i.e. instead of

HostKey ./ssh_host_key

put:

HostKey /home/dmitry/ssh_host_key

or wherever it is.

That error isn't very helpful is it?


FWIW, I just ran into the same error message, but with a different cause. In my case the problem turned out to be that my host private key files were mode 640 instead of 600. A quick chmod and sshd restart solved the problem. I guess the common theme here is sshd not loading the host keys for one reason or another.

Tags:

Linux

Ssh

Rsa