链接:
https://blog.csdn.net/weixin_30367945/article/details/98906731
有两个提示 Could not load host key: /etc/ssh/ssh_host_rsa_key 和 Could not load host key: /etc/ssh/ssh_host_dsa_key ,此时如果从客户端连接到服务器时是不会成功的。其原因是在 SSH 连接协议中需要有 RSA 或 DSA 密钥的鉴权。 因此,我们可以在服务器端使用 ssh-keygen 程序来生成一对公钥/私钥对
运行下面命令:
root@bt:/etc/ssh# ssh-keygen -t rsa -b 2048 -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:
3b:a4:b8:df:a9:15:d1:62:df:d5:d1:41:50:59:4a:96 root@bt
The key's randomart image is:
+--[ RSA 2048]----+
| .***|
| . oE+o|
| + . o .|
| . + . . |
| S . . |
| . o o |
| . . + |
| . o o |
| ..o.o |
+-----------------+