SSH-Tunnel 定期出现“远程转发失败”

问题描述 投票:0回答:0

我已经配置了一个反向 ssh 隧道来将我的本地机器连接到一些云资源。

我在本地机器上使用的命令:

/usr/lib/autossh/autossh -vv -M 0 \
    -o ExitOnForwardFailure=yes -o StrictHostKeyChecking=accept-new \
    -o TCPKeepAlive=no -o ServerAliveInterval=10 -o ServerAliveCountMax=5 \
    -i <ssh-key> -NgR 1061:localhost:22 <public-ip> -p 2222

偶尔(通常一天一次,有时一天 5 次)连接会因错误而关闭 ...

debug1: remote forward failure for: listen 1061, connect localhost:22
Error: remote port forwarding failed for listen port 1061

这是预期的,因为我正在指定

ExitOnForwardFailure
但我不明白的是为什么这种情况只是有时发生,而且似乎只是在很短的时间内发生。如果我等待 2-3 分钟并尝试再次创建隧道,它将毫无问题地连接。任何提高可靠性的建议都值得赞赏。

  • 我在远程机器上设置了
    GatewayPorts yes
  • netstat
    在关闭窗口期间,远程机器上没有显示任何东西蹲在端口上
  • ssh
    可以在down window期间连接,只是不能转发端口。
jenkins networking ssh-tunnel
© www.soinside.com 2019 - 2024. All rights reserved.