前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >kex_exchange_identification: read: Connection reset by peer

kex_exchange_identification: read: Connection reset by peer

原创
作者头像
对你无可奈何
修改2023-07-08 16:20:22
3.9K0
修改2023-07-08 16:20:22
举报
文章被收录于专栏:运维专栏

服务器ssh 密钥连接一直很正常的,今天重启了一下电脑,突然就连不上了:

代码语言:txt
复制
[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
image.png
image.png

突然就方了怎么回事。网上搜索都是一些无效搜索:

image.png
image.png

找到了某云的文档,顿时明悟:

使用SSH客户端登录Linux实例提示“ssh_exchange_identification: read: Connection reset by peer”错误怎么办?

image.png
image.png

想到了前几天服务器加了以下脚本并加入计划任务:

代码语言:txt
复制
#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在里面:

image.png
image.png

解决方法就是 将IP添加到host.allow文件中去:

代码语言:txt
复制
sshd:xx.xxx.xxx.22:allow

第一次在某云文档这里找到对我有用的东西!感谢!

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
相关产品与服务
云服务器
云服务器(Cloud Virtual Machine,CVM)提供安全可靠的弹性计算服务。 您可以实时扩展或缩减计算资源,适应变化的业务需求,并只需按实际使用的资源计费。使用 CVM 可以极大降低您的软硬件采购成本,简化 IT 运维工作。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档