kex_exchange_identification: Connection closed by remote hostshell
經過內網主機或者遠程主機ssh登錄機率性失敗,最高登錄失敗率達到80%左右。服務器
內網win主機登錄表現爲登錄失敗,須要反覆登錄屢次,由於這臺主機是我內網的集中管控服務器,不能輕易的重裝或者調整,整個大內網都靠它去監控和維護。期間嘗試過更改各類配置,包括某乎帖子中的各類操做。 無效!!!併發
我只能默默的忍受~運維
個人解決辦法是在xshell創建快捷方式,而後瘋狂點擊快捷方式登錄,好幾個月的運維工做都是這麼DT的過的,直到我,,,,不再想忍受了。
ssh
嘗試從別的服務器ssh登錄,報錯信息以下:ide
[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 hostdebug
百度報錯信息無果,全是這個報錯信息ssh_exchange_identification: Connection closed by remote host,根本沒有我要找的KEX,無奈,只能嘗試更改並行登錄參數和最大鏈接數。blog
MaxSessions:最大容許連接數,默認10.進程
MaxStartups:最大容許保持多少個未認證連接(未輸入登陸密碼),默認值是10.rem
#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服務世界終於太平無事了。原來都是併發鏈接惹的禍。