启动ssh服务时,提示Could not load host key: /etc/ssh/ssh_host_rsa_key
2012-03-16 17:14
591 查看
在启用 ssh 服务时,有时会看到如下提示:
root@bt:~# /etc/init.d/ssh start
* Starting OpenBSD Secure Shell server sshd
Could not load host key: /etc/ssh/ssh_host_rsa_key
Could not load host key: /etc/ssh/ssh_host_dsa_key
有两个提示 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 |
+-----------------+
上面 ssh-keygen 命令中,-t 选项表示生成的密钥所使用的加密类型,这里选择的是 RSA ;-b 选项表示 bit,后接一个整数,表示加密的位数,该数值越大表示加密的强度越高;-f 选项后接要生成的密钥文件名。根据 /etc/ssh 目录下的 sshd_config 配置文件,RSA 密钥默认识别文件名为 ssh_host_rsa_key 。
命令执行成功后,在 /etc/ssh 下会看到有两个文件生成:ssh_host_rsa_key 和 ssh_host_rsa_key.pub ,前者是私钥,后者是公钥。这样,当再次用 putty 连接时,首先会提示服务器端的加密指纹已经被修改,如果信任则点 yes 继续,否则断开,这里当然是选择信任 yes 。此后,客户端将用公钥对数据进行加密后发往服务器,而服务器收到数据后则用私钥进行解密。
root@bt:~# /etc/init.d/ssh start
* Starting OpenBSD Secure Shell server sshd
Could not load host key: /etc/ssh/ssh_host_rsa_key
Could not load host key: /etc/ssh/ssh_host_dsa_key
有两个提示 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 |
+-----------------+
上面 ssh-keygen 命令中,-t 选项表示生成的密钥所使用的加密类型,这里选择的是 RSA ;-b 选项表示 bit,后接一个整数,表示加密的位数,该数值越大表示加密的强度越高;-f 选项后接要生成的密钥文件名。根据 /etc/ssh 目录下的 sshd_config 配置文件,RSA 密钥默认识别文件名为 ssh_host_rsa_key 。
命令执行成功后,在 /etc/ssh 下会看到有两个文件生成:ssh_host_rsa_key 和 ssh_host_rsa_key.pub ,前者是私钥,后者是公钥。这样,当再次用 putty 连接时,首先会提示服务器端的加密指纹已经被修改,如果信任则点 yes 继续,否则断开,这里当然是选择信任 yes 。此后,客户端将用公钥对数据进行加密后发往服务器,而服务器收到数据后则用私钥进行解密。
相关文章推荐
- 启动ssh服务时,提示Could not load host key: /etc/ssh/ssh_host_rsa_key
- 启动ssh服务时,提示Could not load host key: /etc/ssh/ssh_host_rsa_key
- could not load host key: /etc/ssh/ssh_host_rsa_key 无法启动ssh的一个解决办法
- could not load host key: /etc/ssh/ssh_host_rsa_key 无法启动ssh的一个解决办法
- NetBSD could not load host key: /etc/ssh/ssh_host_rsa_key 无法启动ssh的一个解决办法
- SSH 提示Could not load host key: /etc/ssh/ssh_host_rsa_key
- Could not load host key: /etc/ssh/ssh_host_rsa_key
- Could not load host key: /etc/ssh/ssh_host_rsa_key /etc/ssh/ssh_host_dsa_key问题
- ssh报错:Could not load host key:/etc/ssh/ssh_host_rsa_key&ssh_host_ecdsa_key&ssh_host_ed25519_key
- sshd 无法启用的问题 Could not load host key: /etc/ssh/ssh_host_rsa_key Could not load host key: /etc/ssh/ss
- could not load host key: /etc/ssh/ssh_host_rsa_key SSH无法连接
- 全志open-ssh Could not load host key: /etc/ssh/ssh_host_key问题
- ssh异常-Could not load host key: /etc/ssh/ssh_host_ed25519_key
- 启动sshd时,报“Could not load host key”错
- 启动sshd时,报“Could not load host key”错
- 启动sshd时,报“Could not load host key”错
- 启动nginx服务提示 nginx: [emerg] still could not
- 如何修复“sshd error: could not load host key”
- hadoop启动时,报ssh: Could not resolve hostname xxx: Name or service not known
- hadoop启动时,报ssh: Could not resolve hostname xxx: Name or service not known