Skip to content

X11Forwarding

X11Forwarding yes wasn't a feature I used all to frequently until I started living in a multi level house. Oh and that little detail of co-habiting a Windows 10 laptop as my daily driver. Now I find it quite useful in my daily workflow.

Windows

First step is to get X onto Windows which is really well supported.

Options:

X410 - Pros - Free tier - Install from the Windows Store here - WSL support - Cons - Paid tier has basic options pay walled - Closed source - Revenue driven

VcXsrv - Pros - Command line utility - Open source - Well supported and active community - Cons - Not as flashy or well designed UI

MobaXterm - Pros - Tools galore - that just work - Quake style terminal - Cons - Closed source - A lot of functionality

Winner

I chose MobaXterm for the time being after testing both X410 and VcXsrv which I was unable to get working. The base Windows install still has VcXsrv installed which I am determined to get configured with the default Windows Terminal.

Problems

I still don't have X forwarding in the default shell but MobaXterm is working no problem. This leads me to believe the issue is with Windows and how X is configured.

MobaXterm Welcome Message 🤲

I couldn't figure out if the issue was server or client side until I installed MobaXterm. I connected to the server and MobaXterm has a great motd console output with a little ✔ or ❌ indicator which helped me identify a NixOS config error and verify Ubuntu was configured correctly.

The journey of XForwarding on Ubuntu & NixOS

I would like to stop this journey already and say that I could have side stepped all this headache and just used Docker. But the idea of co-habiting is to blend Windows into a real workflow with as few tools as possible and I don't wan't to junk up the menu or notification system.

Hitting Walls

I was having issues getting X to forward even though the appropriate settings were enabled in the sshd_config and each distribution had their dependencies met.

Ubuntu:

sudo apt install --no-install-recommends xserver-xorg x11-xserver-utils
sudo apt install xauth
sshd_config
X11Forwarding yes
X11DisplayOffset 10
NixOS:

There is a whole XFCE desktop enabled on the testing machine you can see the config stanza here.

  services.openssh = {
    enable = true;
    ports = [ 22 ];
  };
  programs.ssh.forwardX11 = true;
  services.openssh.settings.X11Forwarding = true;

  environment.systemPackages = with pkgs; [
   xorg.xauth
  ];

I had installed and tested both X410 and VcXsrv on the Windows host with no success since I was determined to get X11Forwarding on the Windows host to use the default terminal. At this point I had no idea where the problem was.

So I fired up MobaXterm, connected to the server, and that glorious motd gave me all the information I needed... It also gave a properly configured X server for Windows out of the box. Okay well MobaXterm for the win if you need a feature rich terminal and X11forwarding. I really wish I could have setup the default Windows terminal to support my X11forwarding needs.

Ubuntu was configured correctly and issuing a start command for a gui application worked as expected.

NixOS X11Forwarding

Once I logged into the Nix system MobaXterm gave me a fat ❌ X11-Forwarding.

As we saw from the snipped above, SSH was enabled on port 22, both programs.ssh.forwardX11 = true; and services.openssh.settings.X11Forwarding = true; and the xorg.xauth package is installed globally.

Why was this not working?

Solution

Keep the xorg.xauth package installed, and adjust your services.openssh config.

  services.openssh = {
    enable = true;
    ports = [ 22 ];
    settings = {
      X11Forwarding = true;
      PasswordAuthentication = true;
    };
  };

You can remove these lines since X11Forwarding was brought inside the services stanza.

  programs.ssh.forwardX11 = true;
  services.openssh.settings.X11Forwarding = true;