"Could not load host key" error when starting sshd
Phenomenon: When you start the SSHD service, the client does not connect to the SSHD server, although it appears that the service started successfully.
As follows:
- [Root@aefe8007a17d ~]#/usr/sbin/sshd
- Could not load host key:/etc/ssh/ssh_host_rsa_key
- Could not load host key:/etc/ssh/ssh_host_ecdsa_key
- Could not load host key:/etc/ssh/ssh_host_ed25519_key
Reason:
1. From the prompt information is that the sshd daemon cannot load the host key file because these key files cannot be found (the key file name and path are defined in profile/etc/ssh/sshd_config);
2. General OpenSSH service after normal installation, the host will automatically generate the corresponding master key file, but here for unknown reasons and did not complete this step, resulting in the inability to remote SSH connection.
Check that the key file exists (there is another phenomenon: The key file exists, but the file size is 0):
- [Root@aefe8007a17d ~]# ll/etc/ssh/
- Total 252
- -rw-r--r--1 root root 242153 Mar 22:18 moduli
- -rw-r--r--1 root root 2208 Mar 22:18 ssh_config
- -RW-------1 root root 4361 Mar 22:18 sshd_config
Regenerate the host key file:
1. Generate Rsa_key (-T indicates the type of encryption used to generate the key; the-f key followed by the key file name to generate);
- [root@aefe8007a17d ~]# ssh-keygen-t rsa-f/etc/ssh/ssh_host_rsa_key
- Generating public/private RSA key pair.
- Enter passphrase (empty for no passphrase):
- Enter same Passphrase again:
- Your identification has been saved In/etc/ssh/ssh_host_rsa_key.
- Your public key has been saved in/etc/ssh/ssh_host_rsa_key.pub.
- The key fingerprint is:
- 5e:2d:19:51:b1:e3:e0:60:65:53:e4:14:f8:d8:38:af root@aefe8007a17d
- The key ' s Randomart image is:
- +--[RSA 2048]----+
- | ==bo |
- | o.=. |
- | o o=+ |
- | . O+*o. |
- | S =oo |
- | . . .. |
- | . . |
- | E |
- | |
- +-----------------+
- [root@aefe8007a17d ~]# ssh-keygen-t ecdsa-f/etc/ssh/ssh_host_ecdsa_key
2. Generate Ecdsa_key;
- [root@aefe8007a17d ~]# ssh-keygen-t ecdsa-f/etc/ssh/ssh_host_ecdsa_key
3. Generate Ed25519_key.
- [root@aefe8007a17d ~]# ssh-keygen-t ed25519-f/etc/ssh/ssh_host_ed25519_key
Once again, check that the key file is present and compliant, and you can see that the corresponding host key file has been generated (actually the master key file is the private key and the. pub file is the public key):
- [Root@aefe8007a17d ~]# ll/etc/ssh/
- Total 276
- -rw-r--r--1 root root 242153 Mar 22:18 moduli
- -rw-r--r--1 root root 2208 Mar 22:18 ssh_config
- -RW-------1 root root 227 16:48 Ssh_host_ecdsa_key
- -rw-r--r--1 root root 179 may 16:48 ssh_host_ecdsa_key.pub
- -RW-------1 root root 411 16:48 Ssh_host_ed25519_key
- -rw-r--r--1 root root 16:48 ssh_host_ed25519_key.pub
- -RW-------1 root root 1679 16:48 Ssh_host_rsa_key
- -rw-r--r--1 root root 399 may 16:48 ssh_host_rsa_key.pub
- -RW-------1 root root 4361 Mar 22:18 sshd_config
At this point the client can ssh connected to the SSHD server side:
- [Root@localhost ~]# ssh 172.17.0.2
- The authenticity of host ' 172.17.0.2 (172.17.0.2) ' can ' t be established.
ECDSA key fingerprint is 37:2a:69:46:c4:bd:92:b2:43:b4:cc:42:41:8e:12:2e.
Is you sure want to continue connecting (yes/no)?
http://www.bkjia.com/PHPjc/1128994.html www.bkjia.com true http://www.bkjia.com/PHPjc/1128994.html techarticle When starting sshd, reported "Could Not load host key" error phenomenon: When starting the sshd service, although it appears that the service started successfully, but the client does not connect to the SSHD server side. as follows: [Root@a ...