Score:0

How can I access my Ubuntu machine running X11/Xorg from Windows 10?

cn flag

I have a laptop running Windows 10 (or Windows 11). I can ssh into my Ubuntu computer with ssh [email protected], but I'd like to either (a) use a GUI app from Windows or (b) use the entire desktop from Windows. Ideally, I'd like to do this via X forwarding, rather than VNC or RDP. Note that I'm not using Wayland here.

How can I do this?

Score:1
cn flag

I'll start with two machines. I'll have a recent (22H2) Windows 10 computer and a Ubuntu 23.04 machine. The Ubuntu machine will run stock Ubuntu desktop. I'll be using a minimal install of Ubuntu, but a full installation should work fine to. I further assume that your Ubuntu computer has been configured to run Xorg, not Wayland. This is not the default.


On the Windows machine, download VcXsrv from here, and run the installer. At the time of writing, the file was called vcxsrv-64.1.20.14.0.installer.exe. The version will likely vary over time, though. In the VcXsrv installer, accept the defaults, they are fine.

On Ubuntu, run sudo apt update && sudo apt install openssh-server. Run hostname -I to find your IP address. Let's pick an app to run remotely. I'll choose /usr/bin/gnome-text-edit. On the actual Ubuntu computer (i.e., not over SSH), run /usr/bin/gnome-text-edit. The text editor should open. Close it. We just needed to ensure it worked.

Let's try that from Windows, via SSH. In Windows, run ssh -X username@[Ubuntu IP address here]. That either gave an error like (gnome-text-editor:2524): Gtk-WARNING **: 12:51:24.488: cannot open display:. That wasn't what we wanted. If it opened the text editor, but on the Ubuntu computer, double-check that you're not using Wayland. On Windows, run XLaunch (it's an app, not a shell command). That is what was installed by the VcXsrv installer. Select Multiple windows, and a Display number of three (3). Select Start no client, and check Disable access control, and do Finish.

Find the IP address of your Windows computer by running ipconfig in the terminal (I'm using Powershell). My Windows IP is 192.168.1.141. Now do

DISPLAY='192.168.1.141:3.0' /usr/bin/gnome-text-editor

in the SSH session. The app should launch on Windows. Note that 192.168.1.141 is the IP of your Windows computer, not your Ubuntu computer.

Done! You should be able to do the same thing with any GUI app. Note that this works on Xorg, not Wayland. Also note that I choose a display number of three somewhat randomly. Avoid using one that's already taken, so I picked three, but other numbers that aren't in use should work fine.

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.