xterms 中的 ssh 会话在断开连接时会冻结几分钟

dre*_*ves 7 linux ssh terminal cygwin macos

如果我通过 ssh 连接到远程机器,然后失去互联网连接,会话就会冻结。我无法使用 control-c 或以其他方式中止并返回到我的本地 xterm 或终端提示符,但如果我等待几分钟,它就会这样做。必须有某种方法可以强制它在连接丢失时中止远程 ssh 会话。我在 Mac 上,但我相信这也会发生在 cygwin 或 linux 上。

Jam*_*s T 10

蒂尔达时期应该做你想做的(~.)。一定是回车后输入的第一件事,所以按回车然后输入。这是 ssh 的手动输入:

 -e escape_char
         Sets the escape character for sessions with a pty (default: ‘~’).
         The escape character is only recognized at the beginning of a
         line.  The escape character followed by a dot (‘.’) closes the
         connection; followed by control-Z suspends the connection; and
         followed by itself sends the escape character once.  Setting the
         character to “none” disables any escapes and makes the session
         fully transparent.
Run Code Online (Sandbox Code Playgroud)

ctrl-d 也可能有效。

编辑:SSH 内置了很多转义字符命令。打开活动的 SSH 会话后,您可以按 [enter]~? 查看选项列表。这都在 ssh 的 man 条目中。如果您还不了解 man 条目……您会发现一个奇妙的世界!在 linux 终端中键入“man command”,在这种情况下是“man ssh”,不带引号。它有很多信息。按“q”退出。如果您更喜欢信息界面,也可以输入“info ssh”。