Skip to content

Instantly share code, notes, and snippets.

@strund3r
Last active September 16, 2020 19:42
Show Gist options
  • Save strund3r/6387a4e8c7c34648587d6db192556724 to your computer and use it in GitHub Desktop.
Save strund3r/6387a4e8c7c34648587d6db192556724 to your computer and use it in GitHub Desktop.

GUI Apps Using X11 Forwarding

Installing VcXsrv

Download the latest version from SourceForge.

After installing it, open XLaunch. It will start the first time configuration wizard and will generate a config file by the end.

  1. Display settings: select “Multiple windows” and set the display number to -1. (default)
  2. Client startup: select “Start no client” (default)
  3. Extra settings: leave everything as is but check “Disable access control”. By default, VcXsrv only allows incoming connections from localhost and the like. We need VcXsrv to accept connections from outside. Don’t worry, we’ll go over firewall configuration to make this safer later.
  4. Save the configuration file somewhere convenient. You’ll open it whenever you want to start the X server in the future. I put it on my desktop.

When you start the VcXsrv for the first time, windows firewall will prompt you about allowing incoming connections to it. Check public networks.

Doing so will give all incoming connections from public networks access to your X server. Our next step will be configuring a tighter firewall rule to only allow incoming connections.

Configuring Windows Firewall (If Needed)

First of all, run ifconfig or ip a on your server terminal and look for the inet field under your network device.

Next, get to the Windows Defender Firewall with Advanced Security and follow this slides to set up a new inbound firewall rule.

After that, disable the automatic rules that Windows generated after we clicked through the firewall prompt when we first launched VcXsrv. There should be two inbound rules named “VcXsrv windows xserver”. Right click to disable them both.

Set the environment variables

On your server, set the DISPLAY environment variable. You may need to do this every time you start a new session. You can add it to your .bash_profile to do so.

export DISPLAY=<YOUR-IP>:0.0

If you have a high resolution display, you may need to also set the GDK_SCALE environment variable.

export GDK_SCALE=2

References

Based on Chuck Dries' Installing GitKraken in WSL 2 article

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment