报错如下: ssh_exchange_identification: read: Connection reset by peer lost connection

问题原因

该问题通常是由于 Linux 系统通过 /etc/hosts.allow 或 /etc/hosts.deny,启用了 TCP Wrapper 访问控制所致。

处理办法

要解决此问题,请进行如下配置检查和修改:

通过 管理终端 进入系统。 通过 cat 等指令查看 /etc/hosts.allow 或 /etc/hosts.deny中是否包含类似如下配置: all:all:deny 如果需要修改相关策略配置,在继续之前建议进行文件备份。 使用 vi 等编辑器,按需修改 /etc/hosts.allow 和 /etc/hosts.deny中的相关配置,或者整个删除或注释(在最开头添加 # 号)整行配置。比如: all:all:deny

vi /etc/hosts.allow 其他全部注释,追加: sshd: ALL

重启ssh就ok了

service sshd restart (centos6) systemctl restart sshd (centos7)