Skip to content

X-Forwarding on Linux

X11 forwarding allows a user to launch applications and see a graphical representation of the application running on a remote machine using functionality embedded in the X-Server protocols common across many Linux (and other) platforms.

Linux-based operating systems fully support X-Forwarding for accessing graphical content over an SSH Connection. The SSH connection will commonly be to a Linux environment, but there are also other operating systems that support X-Windows and X-Forwarding connections.

Note

This document was tested using a default installation of Ubuntu Desktop 22.04 running Gnome on Wayland. Linux configurations vary wildly, your mileage may vary.

Prerequisites

Under Linux where a desktop environment is present, there are usually no prerequisites for launching graphical X applications.

One thing that is worth checking is the DISPLAY environment variable. To do this, type the following at a Terminal prompt:

echo $DISPLAY

The result will usually be something like :0 or :0.0. If there is a result, your DISPLAY variable is probably configured properly.

Screenshot

Testing X-Windows Functionality via Terminal

Open a Terminal window and attempt use of X-Forwarding by connecting to SunLab using the -X SSH command line option:

ssh -X sun123@sunlab.cse.lehigh.edu

Where sun123 is the SunLab username.

Note

The SSH command line option -Y is also a method to enable X-Forwarding, but should only be used on fully trusted platforms as it can open security vulnerabilities. -X is the preferred method to use.

Run an X-Windows compatible program like 'xeyes'. The graphical window should launch automatically (its icon will appear in the Mac Dock) and the X-Windows program will display:

Screenshot