Compiled from: http://ask.xmodulo.com/sshd-error-could-not-load-host-key.html golinux
This address: https://linux.cn/article-4226-1.html
- -Regenerate SSH host key 54%
problem : When I try to ssh to a remote server, the SSH client fails to log in and prompts "Connection closed by x.x.x.x". At the end of the SSH server, I see this error message: "SSHD error:could not load host key." What's wrong with this and how can I fix it?
The detailed symptoms of this SSH connection error are as follows.
SSH client side : When you try to ssh to a remote host, you do not see the login screen, your SSH connection immediately shut down, and prompted this message: "Connection closed by x.x.x.x".
SSH server aspect : In the System log, you see the following error message (for example, on Debian/ubuntu,/var/log/auth.log).
Oct 16 08:59:45 openstack sshd[1214]: error: Could not load host key: /etc/ssh/ssh_host_rsa_keyOct 16 08:59:45 openstack sshd[1214]: error: Could not load host key: /etc/ssh/ssh_host_dsa_keyOct 16 08:59:45 openstack sshd[1214]: error: Could not load host key: /etc/ssh/ssh_host_ecdsa_keyOct 16 08:59:45 openstack sshd[1214]: fatal: No supported key exchange algorithms [preauth]
The root cause of the problem is that the sshd daemon does not know how to load the SSH host key.
When the OpenSSH server is first installed on a Linux system, the SSH host key should be automatically generated for subsequent use. If, in any case, the key generation process did not complete successfully, that would result in an SSH login problem.
Let's check if we can find the SSH host key in the appropriate location.
If the SSH host key is not found there, or if their size is truncated to 0 (as in the above), you will need to regenerate the host key from the beginning.
Regenerate SSH host key
On Debian, Ubuntu, or its derivative version, you can use the Dpkg-reconfigure tool to regenerate the SSH host key, as follows:
On CentOS, Rhel, or fedora, all you have to do is delete the existing (problematic) key and restart the sshd service.
$ sudo rm -r /etc/ssh/ssh*key$ sudo systemctl restart sshd
Another way to regenerate the SSH master key is to use the Ssh-keygen command to generate it manually.
After generating the new SSH host key, make sure that they are found in the/etc/ssh directory. You do not have to restart the sshd service at this time.
Now, try ssh to the SSH server, and see if the problem has left you.
Via:http://ask.xmodulo.com/sshd-error-could-not-load-host-key.html
Translator: Golinux Proofreading: Wxy
This article by LCTT original translation, Linux China honors launch
[Go] Linux has a question: How to fix "sshd error:could not load host key"