通过SSH挂起计算机后如何恢复终端?


14

我经常将SSH连接到计算机,只是使其进入睡眠状态。问题是当它休眠时,它保持SSH连接打开(似乎无限期)。这是发生了什么:

oli@bert:~$ ssh tank
oli@tank:~$ sudo pm-suspend
[sudo] password for oli:

我输入密码,Return然后点击它,然后挂起...直到唤醒远程计算机。

有什么方法可以强制在本地断开连接,这样我就可以不必关闭终端再启动另一个终端就可以将其退回?


奥利:根据您的工作,您可以使用屏幕还是通过ssh发送命令?您也可以将键与强制命令一起使用。

Answers:


14

输入SSH转义码!来自man ssh

ESCAPE CHARACTERS
 When a pseudo-terminal has been requested, ssh supports a number of
 functions through the use of an escape character.

 A single tilde character can be sent as ~~ or by following the tilde by a
 character other than those described below.  The escape character must
 always follow a newline to be interpreted as special.  The escape
 character can be changed in configuration files using the EscapeChar
 configuration directive or on the command line by the -e option.

 The supported escapes (assuming the default ‘~’) are:

 ~.      Disconnect.

 ~^Z     Background ssh.

 ~&      Background ssh at logout when waiting for forwarded connection /
         X11 sessions to terminate.

因此:按Enter~.

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.