12.04 - ssh间断阻塞连接

分享于 

4分钟阅读

ubuntu

  繁體

问题:

在运行Ubuntu 12.04的"古老"服务器中,ssh出现间歇性问题,我收到错误消息ssh_exchange_identification: Connection closed by remote host

这是ssh-v从节点5( ventus5 )到主节点( ventus )的输出


meteo@ventus5:~$ ssh -v ventus


OpenSSH_5.9p1 Debian-5ubuntu1.1, OpenSSL 1.0.1 14 Mar 2012


debug1: Reading configuration data /etc/ssh/ssh_config


debug1: /etc/ssh/ssh_config line 19: Applying options for *


debug1: Connecting to ventus [192.168.1.1] port 22.


debug1: Connection established.


debug1: identity file /home/meteo/.ssh/id_rsa type 1


debug1: Checking blacklist file /usr/share/ssh/blacklist.RSA-2048


debug1: Checking blacklist file /etc/ssh/blacklist.RSA-2048


debug1: identity file /home/meteo/.ssh/id_rsa-cert type -1


debug1: identity file /home/meteo/.ssh/id_dsa type -1


debug1: identity file /home/meteo/.ssh/id_dsa-cert type -1


debug1: identity file /home/meteo/.ssh/id_ecdsa type -1


debug1: identity file /home/meteo/.ssh/id_ecdsa-cert type -1


ssh_exchange_identification: Connection closed by remote host




meteo@PINAR:~$ ssh -vvv ventus


OpenSSH_8.2p1 Ubuntu-4ubuntu0.1, OpenSSL 1.1.1f 31 Mar 2020


debug1: Reading configuration data /etc/ssh/ssh_config


debug1: /etc/ssh/ssh_config line 19: include /etc/ssh/ssh_config.d/*.conf matched no files


debug1: /etc/ssh/ssh_config line 21: Applying options for *


debug2: resolving "ventus" port 22


debug2: ssh_connect_direct


debug1: Connecting to ventus [XXX.XXX.XXX.XXX] port 22.


debug1: Connection established.


debug1: identity file /home/meteo/.ssh/id_rsa type -1


debug1: identity file /home/meteo/.ssh/id_rsa-cert type -1


debug1: identity file /home/meteo/.ssh/id_dsa type -1


debug1: identity file /home/meteo/.ssh/id_dsa-cert type -1


debug1: identity file /home/meteo/.ssh/id_ecdsa type -1


debug1: identity file /home/meteo/.ssh/id_ecdsa-cert type -1


debug1: identity file /home/meteo/.ssh/id_ecdsa_sk type -1


debug1: identity file /home/meteo/.ssh/id_ecdsa_sk-cert type -1


debug1: identity file /home/meteo/.ssh/id_ed25519 type -1


debug1: identity file /home/meteo/.ssh/id_ed25519-cert type -1


debug1: identity file /home/meteo/.ssh/id_ed25519_sk type -1


debug1: identity file /home/meteo/.ssh/id_ed25519_sk-cert type -1


debug1: identity file /home/meteo/.ssh/id_xmss type -1


debug1: identity file /home/meteo/.ssh/id_xmss-cert type -1


debug1: Local version string SSH-2.0-OpenSSH_8.2p1 Ubuntu-4ubuntu0.1


kex_exchange_identification: Connection closed by remote host



iptables -nL我发现了这个


Chain sshguard (1 references)



DROP all -- 192.168.1.1 0.0.0.0/0 



SSH-2.0-OpenSSH_5.9p1 Debian-5ubuntu1.10


答案1:

在运行ssh服务器(ventus)的计算机上,运行一些命令以显示ssh服务器进程的日志。在更新的Ubuntu版本,是journalctl -u ssh,但我不确定12.04是什么 --也许是/var/log/auth.log文件?

无论如何,一定要找到由ssh服务器进程生成的日志,你可以看到成功和失败的连接尝试的信息,如果未看到失败的log,则表明问题出在操作系统向ssh服务器进程提供包之前。

另一种方法是使用tcpdumptshark或其他类似的工具(在客户端和服务器端)查看通过网络的数据包,你可以看到数据包是否到达。



相关文章