Xpra for Graphical Applications (Linux)

Summary

You can install and use Xpra on your Linux, Windows, or Mac device to run graphical applications through an SSH connection to a remote Linux computer.

Body

Using a program called Xpra, you can run graphical applications on a remote Linux machine through an SSH connection from all major platforms. To do this, you will need to have SSH access to a machine with Xpra installed, as well as the Xpra client installed on your machine. You can create and connect to an Xpra session on guardian.it.mtu.edu, colossus.it.mtu.edu, and any other machines that have Xpra server installed.

Using Xpra to connect to one of Michigan Tech’s computers will require you to choose a single application to connect to. 

Please note that many applications may not launch at all, while others may work perfectly out-of-the-box or once launched with certain arguments (e.g., --no-remote --no-xshm for Firefox).

Some example programs that you can launch and attach to through Xpra are listed below. To launch a different program, you will need to find the command that launches the application along with any arguments that are necessary.

  • xterm for a basic terminal window that could be used to launch other applications
  • firefox for Firefox (add the --no-remote --no-xshm xpra options)
  • google-chrome-stable for Google Chrome
  • code for Visual Studio Code

Xpra has many additional features, which can be viewed and referenced at the program’s documentation.

Installing the Campus VPN Client

Please note that you must have the VPN installed and connected to start an SSH connection and use X forwarding to many fully managed Linux systems. Please visit the articles below for information about connecting to the VPN.

Download and Install Xpra

Xpra can be installed on Linux, Windows, and Mac machines, and can all be used to connect to Guardian or Colossus or other Linux Office Workstation systems. The Xpra server-side component is already installed on all Fully Managed Linux machines.  Installation of the Xpra client on your local machine is required for all of the following steps.

  1. Start by following the download links and instructions for the proper version of Xpra that matches your operating system from the GitHub repository.
  2. Depending on your machine’s operating system, launching or using Xpra may change. The instructions listed below are for using Xpra on each operating system’s command line prompt. There is a Graphical User Interface for the Xpra client available for each operating system, but it is unstable and not recommended.

Running Xpra from the Command Line (Linux, Windows, macOS)

Open a command line prompt on your local machine to enter the commands necessary to use Xpra. If you are not familiar with the command line interface or using SSH, we recommend you see the following resources for more information:

Individuals using Windows with Xpra may have to follow additional steps to get the Xpra command into their PATH environment variable, or will have to use the absolute command path in place of xpra to run these commands. The typical installation path of Xpra on Windows is C:\Program Files\Xpra, and the program can be run by using C:\Program Files\Xpra\Xpra_cmd.exe

  1. Start by SSHing into the remote machine from your command line interface.
    1. SSH into the machine and run the following command after you connect to the campus VPN. Your username is your Michigan Tech account name if you are trying to connect to an on-domain machine.
      ssh <username>@<hostname>
    2. You will be prompted to enter your Michigan Tech ISO password. Please note that the password does not show when typing in the password.
  2. Choose an application with which you would like to use Xpra. 
    1. Run the following command to start an Xpra session with the application or command. For example, if you would like to launch the program xterm, you can run the following command
      xpra start --exit-with-children --start-child='xterm'
    2.  An application window will not appear after running this command, but that’s okay! You will see some additional output indicating that the session is running. After the session has started, you will see a line that indicates the display used (Actual display used :0). Remember this number, as you will use it to connect to the Xpra server on your local machine.
  3. Exit out of your SSH session using the exit command.
  4. On your local machine, run the following command to attach to the remote machine’s Xpra session
    xpra attach ssh:<username>@<hostname>:0
    1. Replace the :0 with the actual display used in Step 2. Depending on how many Xpra sessions are running on the server, this number may vary, and changing it can lead you to the wrong session.
    2. You will be prompted to input your password for this machine for the username you provided. Please note that there may be extra information outputted along with this prompt, so look at the bottom of the prompt for the password prompt.
    3. A window should appear with the application that you started on the remote machine.
    4. If you receive an error message that states Error: failed to receive anything you will need to SSH back into the remote machine and run the xpra stop all command to stop all Xpra sessions (and go through the steps again)
  5. Once you are finished with your session, you can close out the graphical window or use CTRL+C in the command prompt to quit the program. When you close out the graphical window with the --exit-with-children flag used to launch the Xpra session, the session should automatically close.
    1. You will need to SSH back into the machine using the instructions from Step 1 to stop the Xpra session. Once you have SSHed into the machine, you can run the command xpra stop all to stop all sessions.
    2. Xpra’s wiki notes that audio forwarding constantly uses CPU and network bandwidth, if you do not require it you may experience better results by disabling it by adding --pulseaudio=no to the xpra start command.

Details

Details

Article ID: 144168
Created
Tue 6/14/22 11:27 AM
Modified
Wed 9/4/24 11:33 AM