ssh_exchange_identification: read: Connection reset by peer
现象比较特殊
192.168.9.161这台机子 连接同一个局域网的192的机子的22端口 没有问题,但是访问阿里云服务器的22端口(2个不同账号下的机子 都不能登陆,telnet显示端口是通的 只是直接被关闭了),没法登陆报错ssh_exchange_identification: read: Connection reset by peer,但是访问阿里云服务器的222端口可以连接,其余80 443 可以正常访问。
安全组规则是没问题的
其余方法都试了都不可以,只能通过修改目标机子ssh配置 同时开发一个222出来 就可以连接 暂时这样解决,无法ssh 阿里云机子22端口的原因还没找到。
同一个局域网对外的ip不一致,并且161这台ssh 222端口的时候 显示的外网ip还和curl cip.cc出来的结果不一致。怀疑是网络之类的问题。
修改ulimt的值 调大调大
修改/etc/hosts.allow 和/etc/hosts.deny
echo sshd: ALL > /etc/hosts.allow
echo "" > /etc/hosts.deny
service sshd restart
排查服务配置是不是有问题
$(which sshd) -Ddp 22
清除缓存
echo 3 > /proc/sys/vm/drop_caches
从原来的read Connection reset by peer 变成了write Connection reset by peer,再变成read Connection reset by peer
查看日志 尝试发现问题
# 基本没有屁用
ssh -vvv root@host -p port
关闭防火墙
service iptables stop
systemctl stop firewalld
清理known_hosts
cat /dev/null > /root/.ssh/known_hosts
修改/var目录权限
cd /var
chmod -R 755 *
修改/etc/ssh/sshd_config 配置文件
MaxStartups #为设置最大SSH连接数
ClientAliveInterval # 设置多长秒无事件后,发送Alive信息
ClientAliveCountMax # 设置发送几次Alive无反应后,解除此SSH连接。
# 这里为 6 × 3 = 18分钟
# 后两个属性原本没有,自行添加。
# 重启ssh服务之后发现不是这个问题导致
修改/root/.ssh文件权限
# 先查看后修改
ls -la .ssh/
total 20
drwx------ 2 torxed users 4096 Sep 3 2013 .
drwx------ 51 torxed users 4096 May 11 11:11 ..
-rw------- 1 torxed users 1679 Sep 3 2013 id_rsa
-rw-r--r-- 1 torxed users 403 Sep 3 2013 id_rsa.pub
-rw-r--r-- 1 torxed users 170 May 11 11:21 known_hosts
tcpdump抓包
yum -y install tcpdump
tcpdump -i ens192 -tnn port 22 -XX and host 47.101.50.209
https://www.cnblogs.com/onlycat/p/11110399.html#/cnblog/works/article/11110399
# win=0 说是client端没有去读过缓存 服务端让他别发了
http://blog.sina.com.cn/s/blog_6ab74eef01016gx1.html
升级openssh
未做测试
重启
未做测试