我已经开始了我的自动见证人的投票时间为30岁的s:
AUTOSSH_POLL=30 AUTOSSH_LOGLEVEL=7 autossh -M 0 -f -S none -f -N -L localhost:34567:localhost:6543 user1@server1它运行得很好:
Sep 5 12:26:44 serverA autossh[20935]: check on child 23084
Sep 5 12:26:44 serverA autossh[20935]: set alarm for 30 secs但是如果我物理上删除了网络电缆,这意味着隧道不能再工作了,autossh不会杀死ssh守护进程。为什么?我知道,如果链接关闭,autossh什么也不能做,但我认为它应该尝试做以下工作:
check on child ...)这就是为什么我要运行autossh:如果隧道发生了什么事情(不管是软件问题还是硬件问题),它应该尝试重新启动它。相反,它只是在等待ssh进程死亡。它不应该尝试重新启动它,即使没有重新建立连接的希望?
什么类型的检查在做自动测试?只需验证ssh是否已启动并运行?它不是在做远距离检查吗?
根据请求,我添加了ssh配置的相关部分:
# (see http://aaroncrane.co.uk/2008/04/ssh_faster)
# The ServerAliveInterval tells SSH to send a keepalive message every 60 seconds while the connection is open;
# that both helps poor-quality NAT routers understand that the NAT table entry for your connection should
# be kept alive, and helps SSH detect when there’s a network problem between the server and client.
ServerAliveInterval 60
# The ServerAliveCountMax says that after 60 consecutive unanswered keepalive messages, the connection should
# be dropped. At that point, AutoSSH should try to invoke a fresh SSH client. You can tweak those
# specific values if you want, but they seem to work well for me.
ServerAliveCountMax 60
TCPKeepAlive yes发布于 2014-10-06 03:44:07
但是如果我物理上删除了网络电缆,这意味着隧道不能再工作了,autossh不会杀死ssh守护进程。为什么?
autossh在客户端机器上运行,因此它不能直接关闭服务器上的ssh守护进程。但是,您可以在服务器上的ClientAliveInterval中为/etc/ssh/sshd_config指定一个非零值(参见man sshd_config),并在服务器上重新启动sshd服务以应用配置更改。然后,在网络断开时,ssh守护进程将在ClientAliveInterval * ClientAliveCountMax秒后(但不是由autossh)终止。
现在,如果您想问“为什么autossh不杀死ssh客户端进程?”,那么您已经指定了-M 0,它关闭了监视。从autossh手册页面:
Setting the monitor port to 0 turns the monitoring function off, and autossh will only restart ssh upon ssh's exit。
您不是使用autossh来监视连接,而是在ServerAliveInterval * ServerAliveCountMax秒超时之后等待ssh退出。在ssh退出之前,您已经请求了60次服务器活动检查,间隔60秒将连续检查分开,因此在ssh客户端退出之前,您将等待一个小时。
您还应该强烈考虑在客户端使用ExitOnForwardFailure选项(请参阅man ssh_config),这样如果不能建立隧道,ssh就会退出,然后autossh可以尝试再次启动ssh。
https://serverfault.com/questions/626461
复制相似问题