运维小结之关于ssh登录问题的解决方法

来源:互联网 发布:东莞制造业知乎 编辑:程序博客网 时间:2024/06/05 16:42
=== ssh登录被拒的解决方法 ===
ssh登录被拒,提示:ssh_exchange_identification: read: Connection reset by peer
可能原因:一./var/empty/sshd权限被更改为777
服务器下进行如下操作
使用命令: service sshd stop
                        /usr/sbin/sshd -d
查看sshd服务的debug信息
若出现: /var/empty/sshd must be owned by root and not group or world-writable信息则/var/empty/sshd权限错误,进行下面的操作,修改/var/empty/sshd权限
  1.使用命令:ll  /var/empty
     查看当前empty文件夹权限,若为drwxrwxrwx(777)
  2.修改/var/empty目录权限
       命令:chmod 755 /var/empty/sshd
            或:chmod 711 /var/empty/sshd
3.重启sshd服务
    service sshd restart
二.在客户端使用sudo ssh 服务器IP -V若提示
OpenSSH_7.2p2 Ubuntu-4ubuntu2.2, OpenSSL 1.0.2g  1 Mar 2016
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Connecting to 116.196.90.60 [116.196.90.60] port 22.
debug1: connect to address 116.196.90.60 port 22: Connection refused
ssh: connect to host 116.196.90.60 port 22: Connection refused
则表明主机IP被服务器拒绝访问,该问题通常是由于 Linux 系统通过 /etc/hosts.allow 或 /etc/hosts.deny,启用了 TCP Wrapper  访问控制所致。
可在服务器端作如下操作:
1.检查/etc/hosts.deny中是否有
sshd:客户端IP地址
或在 /etc/hosts.allow 或 /etc/hosts.deny中有
all:all:deny
2.若出现上述情况将sshd:客户端IP地址   all:all:deny注释或删除
一般情况,备份并修改/etc/hosts.allows添加如下命令
sshd:客户端IP地址
(有博友给出的方法是将/etc/hosts.allow修改为sshd:ALL,针对我个人遇到的问题该方法亲测可行,但感觉并不安全)
问题解决参考以下博文:http://yanue.net/post-163.html
                                        https://help.aliyun.com/knowledge_detail/41485.html
                                        http://blog.csdn.net/woshizhangliang999/article/details/50563247      
                                  http://www.cnblogs.com/starof/p/4709805.html             
原创粉丝点击