我正在使用autossh构建反向ssh隧道,但隧道有时停止工作,我需要杀死autossh并重新启动它。
/etc/cron.d/autossh
@reboot autossh -f -nNT -R 3269:intranet.example.com:3269 public.example.com &autossh似乎仍然处于一种奇怪的状态,在这种状态下,转发端口仍然处于打开状态,但您无法从另一方得到响应。通过重新启动autossh,就可以解决这个问题。
我怎样才能防止这个问题的发生?
发布于 2017-03-08 13:36:11
使用ServerAliveInterval (值以秒为单位)使ssh客户端经常通过加密通道发送空(保持活动)数据包,以检测断开的连接:
/etc/cron.d/autossh
@reboot autossh -f -nNT -R 3269:intranet.example.com:3269 -o ServerAliveInterval=30 public.example.com &您可能还应该在服务器上的ClientAliveInterval中设置相应的/etc/ssh/sshd_config设置,以使服务器也丢弃死客户端连接:
# Drop dead client connections after 10 minutes of inactivity
ClientAliveInterval 600https://askubuntu.com/questions/217513
复制相似问题