Persistent X

From Thom Group Wiki
Revision as of 10:44, 20 March 2020 by Ajwt3 (talk | contribs)
Jump to navigation Jump to search

If your internet connection is a bit flaky, it can be a pain to ssh in again and re-create your work environment. A combination of tmux, autossh and xpra saves the day. Make sure tmux and xpra are installed on your department workstation, and autossh and xpra (and a shell and an X Server (e.g. if not using a linux box, Windows Subsystem for Linux running Ubuntu and VcXsrv)) are installed at home.

Replace instances of WORKSTATION with your workstation name (e.g. hypatia). This assumes you have setup a tunnel through citadel (via your .ssh/config) along with something like ssh-agent to handle automatic forwarding of keys, such that you can type

user@HOME$ ssh WORKSTATION

to connect directly to your workstation (including X forwarding) without any faff with keys. Now run xpra on your home machine

user@HOME$ xpra start ssh:WORKSTATION --start-child=xterm

This will bring up an xterm on your workstation, forwarded through an ssh tunnel so the window comes up on your home machine. You can freely start X applications. Try

user@WORKSTATION$ xeyes &

This should follow your mouse cursor around.

Now test the resilience of your connection by turning off your internet. You should see 'disconnected' spinners appear on the xterm and xeyes windows.

Now turn on your internet connection again. The xpra session will probably break at this point, as it doesn't know how to automatically reconnected. You can do this manually with

xpra attach ssh:WORKSTATION

This should bring up things where you left off. If you're even more lazy and want it to automatically reconnect, use autossh:

xpra --ssh="autossh" attach ssh:WORKSTATION

tmux instructions to follow...

Bugs

ssh-agent key forwarding is not persistent currently.