如何防止 gnu 屏幕在失去 SSH 连接后变得无响应?
我使用 VPN 隧道连接到我的工作网络,然后使用 SSH 连接到运行 cygwin 的工作 PC。登录后,我可以附加到屏幕会话,一切都很好。
现在,过了一段时间,当我离开计算机时,VPN 隧道迟早会超时。两端的 SSH 连接最终都会超时,然后我最终会回到我的计算机上做一些工作。从理论上讲,这应该是一个简单的问题,只需重新启动 VPN,通过 SSH 重新连接,然后运行“screen -r -d”即可。
然而,显然当 sshd 守护进程在 cygwin PC 上超时时,它会使屏幕会话处于某种挂起状态。当运行屏幕会话时,我可以通过单击 cygwin bash shell 窗口上的关闭框来重现类似的挂起状态。
一旦发生这种情况,有什么方法可以让屏幕会话恢复,这样我就不会丢失任何东西?
I use a VPN tunnel to connect to my work network and then SSH to connect to my work PC running cygwin. Once logged in I can attach to a screen session and everything works great.
Now, after a while, I walk away from my computer and sooner or later, the VPN tunnel times out. The SSH connection on each end eventually times out and then I eventually come back to my computer to do some work. Theoretically, this should be a simple matter of just restarting the VPN, reconnecting via SSH, and then running "screen -r -d".
However apparently when the sshd daemon times out on the cygwin PC, it leaves the screen session in some kind of hung state. I can reproduce a similar hung state by clicking the close box on a cygwin bash shell window while it's running a screen session.
Is there any way to get the screen session to recover once this has happened, so that I don't lose anything?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
经过大量的实验,我能够恢复屏幕会话,如下所示:
With a great deal of experimentation, I was able to recover the screen session as follows:
screen
阻塞在(死的)SSH 会话的 pty 上。通过终止该sshd
来恢复。假设 Linux,并且您当前不在屏幕内:
screen
is blocking on the (dead) SSH session's pty. Recover by killing thatsshd
.Assuming Linux, and that you're not currently inside screen: