X forwarding (without the pain)
I have never been a big fan of VNC. VNC is cumbersome to setup. You need to create a configuration file for each user and also start a VNC server for each user. Also, having access to a complete desktop feels a bit awkward, when all you want is access to one or two applications. When I need remote access to a machine I usually rely on SSH. However, in my previous job, there were a numerous occasions I had to get access to a graphical user interface over a slow network link. For instance, on some machines, serial over lan would not work and we had to use a graphical tool to access a remote console. I usually used
ssh -X
, but that can be painfully slow over remote links.
So when I had a few moments to spare, I decided to look for an alternative package and stumbled across xpra. xpra works like regular X forwarding, but it is much faster. It auto-negotiates speed, so it is also usable across slower networks links. It is Open Source, unlike alternatives such as NX. Another advantage is that it allows you to detach from a session and easily reattach later. It is configuration file free, all you need is ssh access to the server on which you want to start GUI applications.
You need to install the xpra package on both client and server machines. The packages can be downloaded from winswitch, where they also have repository files for Centos and Ubuntu. In my case I wanted to connect my home server Q with my laptop X220.
On Q:
~# rpm --import https://winswitch.org/gpg.asc
~# yum-config-manager --add-repo https://winswitch.org/downloads/CentOS/winswitch.repo
~# yum install xpra
On X220:
~# curl http://winswitch.org/gpg.asc | apt-key add -
~# echo "deb http://winswitch.org/ xenial main" > /etc/apt/sources.list.d/winswitch.list
~# apt install software-properties-common >& /dev/null
~# add-apt-repository universe >& /dev/null
~# apt update
~# apt install xpra
That's all to install the programs. To start a session, from X220 I can do:
~# xpra start ssh:hans@Q:100 --start-child=sakura
This will start a terminal on DISPLAY 100 and start the sakura terminal emulator direcly. (gnome-terminal and guave did not work, since they are too tighly integrated with the desktop environment. You can start gnome-terminal from a regular shell on Q, bit not as a start-child parameter.) To install sakura on Q I needed to enter the following commands:
~# yum-config-manager --enable epel-testing
~# yum install sakura
~# yum-config-manager --disable epel-testing
Alternatively you can of course use ssh to gain access to the terminal window, but they you will need to set the DISPLAY variable manually.
~# ssh hans@Q DISPLAY=:100 VirtualBox
If the client loses its connection, you can reattach to it later. The previously open windows will reappear on your local desktop and all window state will be preserved.
~# xpra attach ssh:hans@Q:100