3
votes

I'm having an issue where attempting to detach a remote, active IPython session (via Tmux) with matplotlib imported, then logging out of SSH hangs. I have to Crtl-C to kill the process. When I SSH back into the machine, the tmux process is gone.

Example 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

I did get an error once about the X11 session being terminated. I think this is because I'm using ssh -Y to have X11 forwarded for graphics.

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

Is there a way to run matplotlib within IPython/Python and detach the tmux session and logout successfully?

I'm on Linux Mint 18.3 (both local and remote machines), IPython 6.3.1

UPDATE I've googled every potential solution to detaching tmux sessions with X11 forwarding and couldn't get it to work, including putting some DISPLAY code in the .bashrc file. I also tried using xpra, but got an error that the module rencode couldn't be found.

1

1 Answers

0
votes

You can always fall back to the ssh escape sequences:

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

Once you are within tmux and if you just want to terminate your ssh connection, type for example:

~.

Then you can ssh again to the server and do: tmux attach