(反向) ssh 连接“横幅交换期间超时”

(反向) ssh 连接“横幅交换期间超时”

我已经设置了几百个嵌入式盒子,通过打开反向 ssh 隧道与总部联系,每个都在一个新端口下。这基本上工作正常,但今天我在通过低带宽(或低质量?)GPRS 连接使用隧道时遇到了问题。

打开隧道的远程机器通过(目前未知的) 3G 路由器连接到内部,该路由器可能只有 GPRS,最多只有 EDGE 连接。

登录到我的机器后,我可以看到ssh其端口 1234 上的传入连接:

me@machine:~$ sudo nmap -sS -p 1234 --open localhost

Starting Nmap 5.21 ( http://nmap.org ) at 2014-11-27 15:27 CET
Nmap scan report for localhost (127.0.0.1)
Host is up (0.000070s latency).
Hostname localhost resolves to 2 IPs. Only scanned 127.0.0.1
PORT     STATE SERVICE
1234/tcp open  unknown

Nmap done: 1 IP address (1 host up) scanned in 0.09 seconds
me@machine:~$

现在,尝试打开 ssh 连接时出现错误Connection timed out

me@machine:~$ ssh -vp 1234 localhost
OpenSSH_5.9p1 Debian-5ubuntu1.4, 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 localhost [::1] port 1234.
debug1: fd 3 clearing O_NONBLOCK
debug1: Connection established.
debug1: identity file /home/cts/.ssh/id_rsa type 1
debug1: Checking blacklist file /usr/share/ssh/blacklist.RSA-4096
debug1: Checking blacklist file /etc/ssh/blacklist.RSA-4096
debug1: identity file /home/cts/.ssh/id_rsa-cert type -1
debug1: identity file /home/cts/.ssh/id_dsa type -1
debug1: identity file /home/cts/.ssh/id_dsa-cert type -1
debug1: identity file /home/cts/.ssh/id_ecdsa type -1
debug1: identity file /home/cts/.ssh/id_ecdsa-cert type -1
Connection timed out during banner exchange
me@machine:~$

其他端口工作正常,当这个端口(已验证)连接到 3G 网络时,它也同样正常。

我尝试了一些有时有助于通过卫星连接进行此操作的方法 -ssh -o "ConnectTimeout 99" -o "ServerAliveCountMax 5" -vp 1234 localhost但这也没有帮助。

我推测这可能与以下两种情况有关:
a) 无线提供商在其 GPRS 网络上过滤了某些内容(而在其 3G 网络上则没有);
或者
b) GPRS 连接的严重延迟破坏了我的隧道。

有人知道如何解决这种情况或更好地了解这里发生了什么(或者更确切地说,没有发生什么)吗?v顺便说一句,在命令中添加更多 s 不会显示任何调试输出。

答案1

横幅交换期间连接超时错误消息可能表示网络问题。如果您看到在服务器和客户端上使用 netstat 建立了套接字,则可能是防火墙或数据包检查设备阻止了 SSH 连接建立。我们在受保护网络后面的系统上看到了此问题,并且防火墙规则配置不正确。防火墙还丢弃了任何试图发起 HTTP/1.1 请求的连接,这已通过以下方式确认netcat 模拟 Web 服务器并使用 netcat 连接到它。当我们将响应更改为 HTTP/1.2 时,它让响应通过,表明网络层中的某些东西正在检查请求并对其应用过滤规则。

其他低级网络问题(如 MTU/巨型帧问题或高数据包丢失)也可能导致该问题。

答案2

如果您的防火墙(例如在跳转主机上)正在使用被敲只是尝试增加命令超时https://linux.die.net/man/1/knockd

相关内容