Skip to main content

Set Up X-Windows Sharing over SSH

Set up X11 forwarding for SSH connections from Windows 11 to a remote Linux host.

Assumptions

This assumes you are using the built-in ssh command in Windows 11 (provided by OpenSSH).

Prerequisites

  • A Windows PC you want to connect from.
  • A remote Linux PC/VM/LXC you want to connect to.

Setup

On Windows (local):

  • Install VcXsrv from https://sourceforge.net/projects/vcxsrv/
  • Create an environment variable DISPLAY with value localhost:0. This can be done ad hoc in PowerShell or set globally via the system applet.

On Linux (remote host):

  • Install xauth: sudo apt install xauth

Running

From PowerShell on Windows:

  • Start VcXsrv with & 'C:\Program Files\VcXsrv\vcxsrv.exe' :0 -clipboard -multiwindow
  • Set the DISPLAY environment var (if not already set globally) with $env:DISPLAY = "localhost:0"
  • Connect to the remote server and forward X-Windows with ssh -Y <user@server>
  • Run an X-Windows app. (A good test app is xclock, which can be installed via sudo apt install x11-apps)

Note that you may see a warning: "Warning: No xauth data; using fake authentication data for X11 forwarding." This is normal because no auth was set up.

When done:

  • Stop VcXsrv with: taskkill /f /im vcxsrv.exe