Cannot set X11 forwarding from a WSL-machine
I met the same problem and I solved it by setting "DISPLAY=localhost:0.0" instead of "DISPLAY=:0.0" in WSL. Refer to, https://unix.stackexchange.com/questions/57138/why-does-my-x11-forwarding-attempt-fail-with-connect-tmp-x11-unix-x0-no-such
Related videos on Youtube

Comments
-
llinfeng 3 months
I put the following settings into my SSH-enabled remote machines, with the hope that I can launch GUI programs through SSH sessions.
# These settings shall go to `/etc/ssh/sshd_config`. X11Forwarding yes X11UseLocalhost no AllowAgentForwarding yes X11DisplayOffset 10
I use Windows 10 machines with Xming and WSL, locally. On all local+remote machines, I have set
export DISPLAY=0:0
in my~/.bashrc
, which matches the default setting for Xming that are running locally.
Yet, it does different things depending on the host:
- If the host is a Linux machine, when I use
ssh -X [email protected]
to connect and then firegvim
, the GUI is brought to the local machine and all is well; - If the host is a WSL-running Windows 10 machine, while
ssh -X [email protected]
does get me access to the command line of the remote machine,gvim
will instead fire up a GUI session on the remote machine instead.- If I further close the Xming on the remote Windows 10 machine, Gvim will complain that it
"cannot open display"
. This it the same error message when trying to firegvim
on the remote machine locally(Remote Desktop Connecting into that machine). - On the remote Windows 10 machine, I use this command to host the server:
sudo service ssh start
.
- If I further close the Xming on the remote Windows 10 machine, Gvim will complain that it
Question: please advise the proper settings for the Windows 10 machine, so that I can hook up GUI programs via X11. Thx!
More debugging info
Excerpts from
ssh -v -X [email protected]_server
:- From the Linux remote machine:
Warning: No xauth data; using fake authentication data for X11 forwarding. debug1: Requesting X11 forwarding with authentication spoofing. debug1: Sending environment. debug1: Sending env LANG = C.UTF-8 Welcome to Linux Mint 18.1 Serena (GNU/Linux 4.4.0-53-generic x86_64) :: >>Linux-remote<< ::~>>echo $DISPLAY localhost:12.0
After further testing, this number shall increase as I open up new SSH sessions with the Linux remote.
- From the WSL-Windows-10 remote machine:
Warning: No xauth data; using fake authentication data for X11 forwarding. debug1: Requesting X11 forwarding with authentication spoofing. debug1: Sending environment. debug1: Sending env LANG = C.UTF-8 Welcome to Ubuntu 18.04.1 LTS (GNU/Linux 4.4.0-17763-Microsoft x86_64) :: >>WIn-WSL-Machine<< ::~>>echo $DISPLAY 0:0
Repeated "echo-ing" of the
$DISPLAY
in the SSH session with the remote WSL-Windows machine kept showing the same0:0
.PS: I have been testing the X-forwaring on the same local machine, with an Xming server running at local port
0:0
. Such Xming server has been happily accommodating GUI from its "local" Windows WSL shell/system, as well as the Linux machine. It now bugs me that the remote Linux machine should be using a portlocalhost:12.0
-
ivanivan over 3 yearsRemote the
display
export from your login files, and simplyssh -Y [email protected]
-
llinfeng over 3 years@ivanivan. Thanks for the
-Y
flag. Yet, how to properly "remote thedisplay
export from my (local) login files"? -
ivanivan over 3 yearsSorry, typo. Should be "remove the
display
export from ..." -
llinfeng over 3 yearsI removed all
export DISPLAY=0:0
lines from my~/.bashrc
(andfish.conf
). Nothing changed yet ==> I am restarting the WSL-Windows remote now. -
llinfeng over 3 yearsRestarted the remote WSL-Win machine, and same thing: with the [email protected] Xming server running,
gvim
won't throw an error but will drop the GUI window at the remote Windows desktop; shutting down the Xming server running at the remote machine shall leave me with the same error. -
llinfeng over 2 yearsI may have been overcomplicating things per the original post. For now, I have
export DISPLAY=localhost:0.0
in my~/.zshrc
and getxclock
to work both locally (with WSL1) and remotely (with SSH). X410 works perfectly as the "X Server" on the local Windows machine.
- If the host is a Linux machine, when I use