Xephyr for GUI over SSH X-Forwarding


X-Forwarding over SSH is a convenient way to run GUI programs on a remote machine while having them shown on your local desktop. This works well for many programs, but there are a few that do not support X-Forwarding over SSH.

The programs that do not support this are generally using X Server extensions that are not supported over SSH X-Forwarding.

One way to work around this is to use a program called Xephyr, which implements the X11 Server protocol in an X Window. The X Window from Xephyr only needs minimal X Server extensions, all of which are available over SSH X-Forwarding. However, Xephyr supports running programs which require many advanced X Server extensions.


On most Linux distributions, the Xephyr binary is usually either provided by the XOrg Server package, or by a separate package that just contains Xephyr.

On NixOS, the Xephyr binary is provided by the xorg-server package. On Debian/Ubuntu, the Xephyr binary is provided by the xserver-xephyr package.


Using Xephyr is simple. When you are SSH'd into a remote machine with X-Forwarding enabled, run a command like the following:

$ Xephyr -screen 1600x900 :1

This should open up a blank X Window that is 1600x900 in size.

In a separate console, run any GUI program with the DISPLAY environment variable set to :1, as specified to Xephyr. Below, I use drawio. drawio doesn't render correctly when running under normal X-Forwarding, but it does render correctly when running in Xephyr:

$ DISPLAY=:1 drawio

One problem with this is that most GUI programs expect to be run in a window manager. Instead of directly running drawio in Xephyr, it may be easier to run a light-weight window manager in Xephyr, and then run drawio in that window manager.

Here is an example of running the window manager Fluxbox within Xephyr:

$ DISPLAY=:1 startfluxbox

From within Fluxbox, you can open a terminal and directly run drawio.


X-Forwarding over SSH works fine for most programs. But when you have a GUI program that relies on an advanced X Server extension, Xephyr can be a convenient way to run it remotely.

tags: linux