码迷,mamicode.com
首页 > 系统相关 > 详细

Linux ssh key 失效

时间:2014-09-28 19:06:05      阅读:350      评论:0      收藏:0      [点我收藏+]

标签:linux ssh key 失效

处理/etc/ssh/ssh_host_rsa_key 失效问题
处理/etc/ssh/ssh_host_rsa_key 失效问题
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@        WARNING: UNPROTECTED PRIVATE KEY FILE!          @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions 0777 for ‘/etc/ssh/ssh_host_rsa_key‘ are too open.
It is recommended that your private key files are NOT accessible by others.
This private key will be ignored.
bad permissions: ignore key: /etc/ssh/ssh_host_rsa_key
Could not load host key: /etc/ssh/ssh_host_rsa_key
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@        WARNING: UNPROTECTED PRIVATE KEY FILE!          @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions 0777 for ‘/etc/ssh/ssh_host_dsa_key‘ are too open.
It is recommended that your private key files are NOT accessible by others.
This private key will be ignored.
bad permissions: ignore key: /etc/ssh/ssh_host_dsa_key
Could not load host key: /etc/ssh/ssh_host_dsa_key
Disabling protocol version 2. Could not load host key
sshd: no hostkeys available -- exiting.
                                                            [FAILED]
               
如果出现已上bug

1. 备份/etc/ssh/ssh_host_rsa_key
sudo cp /etc/ssh/ssh_host_rsa_key ~/etc/ssh/ssh_host_rsa_key

2. 备份/etc/ssh/ssh_host_dsa_key
sudo cp /etc/ssh/ssh_host_dsa_key ~/etc/ssh/ssh_host_dsa_key

3. 删除原有的这两个配置文件
sudo rm -rf /etc/ssh/ssh_host_rsa_key ; sudo rm -rf /etc/ssh/ssh_host_dsa_key

4. 进行重启sshd服务
sudo /etc/init.d/sshd restart

5. 如果出现以下的错误,再进行配置
Stopping sshd:                                              [FAILED]
Starting sshd: /var/empty/sshd must be owned by root and not group or world-writable.
                                                            [FAILED]

6. 给配置文件授权
chmod 744 /var/empty/sshd
chmod u+rwx /var/empty/ssh/etc/local~
注:如果/var/empty/ssh/etc的属主有执行的权限sshd也是不能成功启动的,需要去掉权限

7. 再次启动sshd服务如果是这样的情况

正确是这样
Stopping sshd:                                             [  OK  ]
Starting sshd:                                             [  OK  ]

如果是这样
Stopping sshd:                                             [FAILED]
Starting sshd:                                             [  OK  ]
再次启动还是这样,则会有问题的,需要再次进行配置

8. 查看sshd进程的侦听状态
比如:
[root@localhost ~]# netstat -natpl | grep sshd
tcp        0      0 0.0.0.0:22                  0.0.0.0:*                   LISTEN      27641/sshd          ##正确的显示方式
tcp        0      0 172.28.88.67:22           172.28.88.68:50692        ESTABLISHED 19493/sshd          ##需要kill
tcp        0      0 172.28.88.67:22           172.28.88.78:56349        ESTABLISHED 25221/sshd          ##需要kill
tcp        0      0 172.28.88.67:22           172.28.88.208:50812        ESTABLISHED 20536/sshd          ##需要kill
tcp        0     52 172.28.88.67:22           172.28.88.18:52873        ESTABLISHED 27550/sshd          ##需要kill
tcp        0      0 :::22                       :::*                        LISTEN      27641/sshd    ##正确的显示方式

9. 再次启动就真没有什么问题

Stopping sshd:                                             [  OK  ]
Starting sshd:                                             [  OK  ]

本文出自 “夜冷” 博客,请务必保留此出处http://miaopan.blog.51cto.com/4233458/1559106

Linux ssh key 失效

标签:linux ssh key 失效

原文地址:http://miaopan.blog.51cto.com/4233458/1559106

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!