服务器ssh 密钥连接一直很正常的,今天重启了一下电脑,突然就连不上了:
[zhangpeng@zhangpeng ~]$ ssh ubuntu@xx.xxx.xxx.xxx
kex_exchange_identification: read: Connection reset by peer
Connection reset by xx.xxx.xxx.xxx port 22
突然就方了怎么回事。网上搜索都是一些无效搜索:
找到了阿里云的文档,顿时明悟:
使用SSH客户端登录Linux实例提示“ssh_exchange_identification: read: Connection reset by peer”错误怎么办?
想到了前几天服务器加了以下脚本并加入计划任务:
#cat /var/log/secure|awk '/Failed/{print $(NF-3)}'|sort|uniq -c|awk '{print $2"="$1;}' > /root/black.txt
DEFINE="5"
for i in `cat /root/black.txt`
do
IP=`echo $i |awk -F= '{print $1}'`
NUM=`echo $i|awk -F= '{print $2}'`
if [ $NUM -gt $DEFINE ]
then
grep $IP /etc/hosts.deny > /dev/null
if [ $? -gt 0 ]
then
echo "sshd:$IP:deny" >> /etc/hosts.deny
fi
fi
done
过滤了以下hosts.deny果真IP在里面:
解决方法就是 将IP添加到host.allow文件中去:
sshd:xx.xxx.xxx.22:allow
第一次在阿里云文档这里找到对我有用的东西!感谢!