ssh_exchange_identification: Connection closed by remote host

问题描述

最近虚拟机经常性的无法连接,小部分时候能尝试登上,大部分时候直接就返回ssh_exchange_identification: Connection closed by remote host

问题解决流程

使用sudo netstat -tnpa | grep 'ESTABLISHED.*sshd'查看主机上ssh的连接情况,发现有很多未知的连接,而且主要是四台机器发起。推测因为这些连接数过多,导致无法新建其他的ssh连接。

直接将这几个IP封掉了sudo iptables -I INPUT -s 需要封掉的IP地址 -j DROP,后续连接就正常了。