"Could not load host key" error _php tutorial when starting sshd

Source: Internet
Author: User

"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:
 
  
  
  1. [Root@aefe8007a17d ~]#/usr/sbin/sshd
  2. Could not load host key:/etc/ssh/ssh_host_rsa_key
  3. Could not load host key:/etc/ssh/ssh_host_ecdsa_key
  4. 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):
 
  
  
  1. [Root@aefe8007a17d ~]# ll/etc/ssh/
  2. Total 252
  3. -rw-r--r--1 root root 242153 Mar 22:18 moduli
  4. -rw-r--r--1 root root 2208 Mar 22:18 ssh_config
  5. -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);
 
 
  1. [root@aefe8007a17d ~]# ssh-keygen-t rsa-f/etc/ssh/ssh_host_rsa_key
  2. Generating public/private RSA key pair.
  3. Enter passphrase (empty for no passphrase):
  4. Enter same Passphrase again:
  5. Your identification has been saved In/etc/ssh/ssh_host_rsa_key.
  6. Your public key has been saved in/etc/ssh/ssh_host_rsa_key.pub.
  7. The key fingerprint is:
  8. 5e:2d:19:51:b1:e3:e0:60:65:53:e4:14:f8:d8:38:af root@aefe8007a17d
  9. The key ' s Randomart image is:
  10. +--[RSA 2048]----+
  11. | ==bo |
  12. | o.=. |
  13. | o o=+ |
  14. | . O+*o. |
  15. | S =oo |
  16. | . . .. |
  17. | . . |
  18. | E |
  19. | |
  20. +-----------------+
  21. [root@aefe8007a17d ~]# ssh-keygen-t ecdsa-f/etc/ssh/ssh_host_ecdsa_key

2. Generate Ecdsa_key;
 
  
  
  1. [root@aefe8007a17d ~]# ssh-keygen-t ecdsa-f/etc/ssh/ssh_host_ecdsa_key
3. Generate Ed25519_key.
 
  
  
  1. [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):
 
  
  
  1. [Root@aefe8007a17d ~]# ll/etc/ssh/
  2. Total 276
  3. -rw-r--r--1 root root 242153 Mar 22:18 moduli
  4. -rw-r--r--1 root root 2208 Mar 22:18 ssh_config
  5. -RW-------1 root root 227 16:48 Ssh_host_ecdsa_key
  6. -rw-r--r--1 root root 179 may 16:48 ssh_host_ecdsa_key.pub
  7. -RW-------1 root root 411 16:48 Ssh_host_ed25519_key
  8. -rw-r--r--1 root root 16:48 ssh_host_ed25519_key.pub
  9. -RW-------1 root root 1679 16:48 Ssh_host_rsa_key
  10. -rw-r--r--1 root root 399 may 16:48 ssh_host_rsa_key.pub
  11. -RW-------1 root root 4361 Mar 22:18 sshd_config

At this point the client can ssh connected to the SSHD server side:
 
  
  
  1. [Root@localhost ~]# ssh 172.17.0.2
  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 ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.