Suspend ssh

ssh 连接到一半,想回到本地,可以 suspend ssh 会话。
输入 ~+<C-z> ,回到本地:

jaseywang@A ~$: ~^Z  [suspend ssh]
[1]+  Stopped                 ssh jaseywang@192.168.1.2

jaseywang@B ~$:

回到本地了。

jaseywang@B ~$: jobs
[1]+  Stopped                 ssh jaseywang@192.168.1.2

继续进行远程会话:

jaseywang@B ~$: fg %1
ssh jaseywang@192.168.1.2

jaseywang@A ~$:

上面的 ~ 符号其实就是 -e 选项的默认参数:

-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.
 

  • http://www.freemindworld.com Li Fanxi

    不错,很实用。

    • http://jaseywang.info jaseywang

      多谢支持,继续努力 :-)