ssh登陆报错

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ssh登陆报错相关的知识,希望对你有一定的参考价值。

:~$ ssh -p 5631 -v *********
OpenSSH_5.1p1 Debian-5ubuntu1, OpenSSL 0.9.8g 19 Oct 2007
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Applying options for *
debug1: Connecting to ******* [**********] port 5631.
debug1: Connection established.
debug1: identity file /home/nbpt/.ssh/identity type -1
debug1: identity file /home/nbpt/.ssh/id_rsa type -1
debug1: identity file /home/nbpt/.ssh/id_dsa type -1
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.1p1 Debian-5ubuntu1
debug1: match: OpenSSH_5.1p1 Debian-5ubuntu1 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_5.1p1 Debian-5ubuntu1
debug1: SSH2_MSG_KEXINIT sent
Read from socket failed: Connection reset by peer
~$ timed out waiting for input: auto-logout

参考技术A

连接被重置。

原因有2个可能:

    客户端未调用完成中断。也就是你代码逻辑有问题

    服务端(数据库)自动中断。如果你用的sql数据库,可能是没有打sp4补丁。

ssh登陆概率性失败,报错:kex_exchange_identification

kex_exchange_identification: Connection closed by remote host

通过内网主机或者远程主机ssh登陆概率性失败,最高登陆失败率达到80%左右。

内网win主机登陆表现为登陆失败,需要反复登陆多次,因为这台主机是我内网的集中管控服务器,不能轻易的重装或者调整,整个大内网都靠它去监控和维护。期间尝试过更改各种配置,包括某乎帖子中的各种操作。 无效!!!

我只能默默的忍受~

我的解决办法是在xshell建立快捷方式,然后疯狂点击快捷方式登陆,好几个月的运维工作都是这么DT的过的,直到我,,,,再也不想忍受了。
技术图片

尝试从别的服务器ssh登陆,报错信息如下:

[root@localhost ]# ssh -vvv tset@192.168.XX.XX
OpenSSH_8.1p1, OpenSSL 1.0.2p 14 Aug 2018
debug1: Reading configuration data /etc/ssh/ssh_config
debug2: resolve_canonicalize: hostname 192.168.XX.XX is address
debug2: ssh_connect_direct
debug1: Connecting to 192.168.XX.XX [192.168.XX.XX] port 22.
debug1: Connection established.
debug1: identity file /root/.ssh/id_rsa type -1
debug1: identity file /root/.ssh/id_rsa-cert type -1
debug1: identity file /root/.ssh/id_dsa type -1
debug1: identity file /root/.ssh/id_dsa-cert type -1
debug1: identity file /root/.ssh/id_ecdsa type -1
debug1: identity file /root/.ssh/id_ecdsa-cert type -1
debug1: identity file /root/.ssh/id_ed25519 type -1
debug1: identity file /root/.ssh/id_ed25519-cert type -1
debug1: identity file /root/.ssh/id_xmss type -1
debug1: identity file /root/.ssh/id_xmss-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_8.1
kex_exchange_identification: Connection closed by remote host

百度报错信息无果,全是这个报错信息ssh_exchange_identification: Connection closed by remote host,根本没有我要找的KEX,无奈,只能尝试更改并行登陆参数和最大连接数。

MaxSessions:最大允许链接数,默认10.

MaxStartups:最大允许保持多少个未认证链接(未输入登录密码),默认值是10.

#MaxStartups 10:30:100 原配置指定SSH守护进程未经身份验证的并发连接的最大数量,默认值是 10:30:100。10:30:100表示的意思是,从第10个连接开始,以30%的概率(递增)拒绝新的连接,指导连接数达到100。

sshd的MaxStartups配置限制了可以并行认证的客户端数量为10,别问我为啥知道,自己登陆上去看cat /etc/ssh/sshd_config |grep MaxStartups 就知道了。

可查看ssh连接数
netstat -nat | grep -i ‘22‘ | wc -l 或者lsof -i:22 |wc -l

我将
MaxSessions 改成 2000
MaxStartups 也改成2000

然后重启sshd服务
世界终于太平无事了。
原来都是并发连接惹的祸。

以上是关于ssh登陆报错的主要内容,如果未能解决你的问题,请参考以下文章

Apollo报错

React 引用报错

ssh登陆概率性失败,报错:kex_exchange_identification

又报错了

ssh登陆概率性失败,报错:kex_exchange_identification

R语言arules报错