【问题标题】:Cannot properly exit SSH session with active IPython/Matplotlib in Tmux无法在 Tmux 中使用活动的 IPython/Matplotlib 正确退出 SSH 会话
【发布时间】:2018-05-02 23:04:04
【问题描述】:

我遇到了一个问题,即尝试使用导入的 matplotlib 分离远程、活动的 IPython 会话(通过 Tmux),然后注销 SSH 挂起。我必须 Crtl-C 来终止该进程。当我 SSH 回到机器时,tmux 进程消失了。

IPython 示例:

~$ ssh-desk # ssh into remote machine
~$ tmux
~$ ipython
In [1]: import matplotlib.pyplot as plt
Crtl-b Crtl-b d
[detached (from session 0)]
~$ tmux ls
0: 1 windows (created Wed May  2 16:52:58 2018) [78x38]
~$ exit
logout
(process hangs here)
Ctrl-c
~$ ssh-desk
~$ tmux ls
no server running on /tmp/tmux-1000/default

我确实收到过关于 X11 会话被终止的错误。我认为这是因为我使用 ssh -Y 将 X11 转发用于图形。

The X11 connection broke (error 1). Did the X11 server die?

有没有办法在 IPython/Python 中运行 matplotlib 并成功分离 tmux 会话并注销?

我使用的是 Linux Mint 18.3(本地和远程机器),IPython 6.3.1

更新 我已经搜索了所有可能的解决方案,以使用 X11 转发分离 tmux 会话,但无法使其工作,包括将一些 DISPLAY 代码放入 .bashrc 文件中。我也尝试使用 xpra,但出现找不到模块 rencode 的错误。

【问题讨论】:

    标签: matplotlib ssh ipython tmux


    【解决方案1】:

    您总是可以退回到 ssh 转义序列:

    sequence | description
    -------- | -----------
     ~.      | terminate connection (and any multiplexed sessions)
     ~B      | send a BREAK to the remote system
     ~C      | open a command line
     ~R      | request rekey
     ~V/v    | decrease/increase verbosity (LogLevel)
     ~^Z     | suspend ssh
     ~#      | list forwarded connections
     ~&      | background ssh (when waiting for connections to terminate)
     ~?      | this message
     ~~      | send the escape character by typing it twice
    

    进入tmux 后,如果您只想终止 ssh 连接,请输入以下示例:

    ~.
    

    然后你可以再次 ssh 到服务器并执行:tmux attach

    【讨论】:

    • 目前这不起作用,因为它会终止 X11 连接,导致“与 localhost:11.0 的 X 连接中断(显式终止或服务器关闭)。”
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-10-09
    • 1970-01-01
    • 2013-01-06
    • 1970-01-01
    • 2017-08-15
    • 2020-08-23
    • 1970-01-01
    相关资源
    最近更新 更多