Install Xpra

Share on:

Overview

Xpra is an open-source multi-platform persistent remote display server and client for forwarding applications and desktop screens.

The Xpra homepage provides the following overview:

It gives you remote access to individual applications or full desktops. On X11, it is also known as screen for X11: it allows you to run programs, usually on a remote host, direct their display to your local machine, and then to disconnect from these programs and reconnect from the same or another machine, without losing any state. It can also be used to forward full desktops, from X11 servers, MS Windows, or Mac OS X.

Ref: Xpra

If you have access to a Cloud environment or powerful server available to run applications, then using something like Xpra will prove useful.

Requirements

In this blog post I am using a Debian 10 virtual machine on Google Cloud. Feel free to use any cloud provider as the implementation should work in a similar fashion. For my environment I have updated the Firewall to allow ingress/inbound traffic on TCP port 8080. The virtual machine used is a small vm capable of testing installation and execution.

Install Xpra

Install Xpra on the remote host machine by following these instructions:

  1. Append the Xpra repository to the sources.list
1echo 'deb https://xpra.org/ buster main' | sudo tee -a /etc/apt/sources.list

2 Add the GPG key to the system

1curl -q https://xpra.org/gpg.asc | gpg dearmor | sudo apt-key add -
  1. Update the packages
1sudo apt update
  1. Install Xpra
1sudo apt install -y xpra

Test Applications

To test, I will be using the following applications to demonstrate Xpra

  • Android Studio
  • VS Code

Android Studio

A basic installation of Android Studio. Test Xpra against is Android Studio.

  • Bind set to 0.0.0.0
  • PORT set to 8080
  • Set output as html
  1. Set the Android Studio Version
1AS_VERSION="2021.1.1.23"
  1. Download the Android Studio archive
1curl -L https://redirector.gvt1.com/edgedl/android/studio/ide-zips/${AS_VERSION}/android-studio-${AS_VERSION}-linux.tar.gz -o android-studio-${AS_VERSION}-linux.tar.gz
  1. Unzip the archive
1tar -xvf  android-studio-2021.1.1.23-linux.tar.gz
  1. Create a script ascode.sh
1tee -a  <<'EOF' > ascode.sh 
2#! /usr/bin/env bash
3 
4# Android application - set to location of your Android installation
5/usr/local/android-studio/bin/studio.sh
6  
7# https://stackoverflow.com/questions/30209776/docker-container-will-automatically-stop-after-docker-run-d
8tail -f /dev/null
9EOF
  1. Copy the script to the path
1cp ascode.sh /usr/local/bin && sudo chmod +x /usr/local/bin/ascode.sh
  1. Start Xpra
1xpra start --bind-tcp=0.0.0.0:8080 --html=on --start=ascode.sh
  1. Go to the browser and open the external IP on Port 8080
1http://[EXTERNAL_IP]:8080
  1. Stop Xpra
1xpra stop

VS Code

A basic installation of VS Code. Test Xpra against is VS Code.

  • Bind set to 0.0.0.0
  • PORT set to 8080
  • Set output as html
  1. Install the gpg key
1curl -sSL https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor | sudo apt-key add -
  1. Add the package channel
1echo "deb [arch=amd64] https://packages.microsoft.com/repos/vscode stable main" | sudo tee -a /etc/apt/sources.list.d/vscode.list
  1. Update the packages
1sudo apt update
  1. Install VS Code
1sudo apt install y code
  1. Create a script vscode.sh
1tee -a  <<'EOF' > vscode.sh 
2#! /usr/bin/env bash
3 
4# VSCode application
5code
6  
7# https://stackoverflow.com/questions/30209776/docker-container-will-automatically-stop-after-docker-run-d
8tail -f /dev/null
9EOF
  1. Copy the script to the path
1cp vscode.sh /usr/local/bin && sudo chmod +x /usr/local/bin/vscode.sh

Run the application

1xpra start --bind=0.0.0.0:8080 --html=on --start=vscode.sh
  1. Go to the browser and open the external IP on Port 8080
1http://[EXTERNAL_IP]:8080
  1. Stop Xpra
1xpra stop