Skip to main content

XPra on Linux

Multi-user support in Linux with full GUI access is somewhat tricky. Solutions based on VNC have a major drawback: all users would share the same session. Proper multi-user support seems only possible using XPra. The process is significantly more involved than setting up other applications since it requires changes to XPra itself.

Steps to install XPra on the VM Image

All the commands in this section need to be executed as root on the VM that prepares the image.

Install XPra

Ubuntu:

wget https://xpra.org/gpg.asc
apt-key add gpg.asc
cd /etc/apt/sources.list.d
wget https://xpra.org/repos/bionic/xpra.list
apt-get update
apt-get install xpra

Debian:

sudo apt-get install xpra

CentOS/RedHat

rpm --import https://winswitch.org/gpg.asc
cd /etc/yum.repos.d/
curl -O https://winswitch.org/downloads/CentOS/winswitch.repo
yum install xpra

Replace XPra service file

The file ``/usr/lib/systemd/system/xpra.service``'s content needs to be replace with:

[Unit]
Description=Xpra Proxy Server
Wants=avahi-daemon.socket
Documentation=https://xpra.org/trac/wiki/Service man:xpra
After=network.target xpra.socket
Requires=xpra.socket
[Service]
Type=simple
EnvironmentFile=-/etc/default/xpra
ExecStart=/usr/bin/xpra proxy :14500 --daemon=no \
--tcp-auth=pam,service=system-auth --html=on
#rely on SIGKILL which returns 128+15=143
SuccessExitStatus=0 143
Restart=on-abnormal
PIDFile=/run/xpra.pid
ProtectSystem=strict
ReadWritePaths=/run /tmp
#PrivateDevices=true
ProtectKernelTunables=true
ProtectControlGroups=true]
[Install]
WantedBy=multi-user.target

Perform this after you install XPra otherwise it will get overwritten.

Modify Xpra configuration

Edit the file at /etc/xpra/conf.d/65_proxy.conf. Change the value of proxy-start-sessions to False.

Disable SELinux

It can easily be done by editing the file /etc/selinux/config and changing the value of SELINUX to disabled.

Install a window manager

The only supported window manager is Xfce4 but others might work.

Ubuntu:

apt-get install xubuntu-desktop

Debian:

apt-get install xfce4

CentOS/RedHat:

yum install -y epel-release
yum groupinstall -y "Xfce"

Modify the VM Image configuration file

See the various sections throughout this document.

  1. in [tunnel.services] add xpra = 14500

  2. in [commands.rootCommands.runOnlyOnceCommands] section add setXdgRuntimeDir = "install -o @:user: -m 700 -d /run/user/$(id -u @:user:)"

  3. in ‘[commands.userCommands.runEveryTimeCommands]` section add ``on_login = {xpra = "bash -c [[ -z xpra list | grep LIVE ]] && xpra start-desktop --start=<windows-manager-session> || exit 0’ "}``

Your final configuration file should look like this:

..
[tunnel.services]
# other services ...
xpra = 14500
...
[commands.rootCommands.runOnlyOnceCommands]
on_login = {setXdgRuntimeDir = "install -o @:user: -m 700 -d /run/user/$(id -u @:user:)"}
...
[commands.userCommands.runEveryTimeCommands]
on_login = {xpra = "bash -c [[ -z `xpra list | grep LIVE` ]] && xpra start-desktop --start=xfce4-session || exit 0' "}
...