-X flag (X11 Forwarding) does not appear to work in Windows

Have you set DISPLAY environment variable on the client? I'm not sure which shell you are using, but with Bourne shell derivative (like bash), please try:

export DISPLAY=127.0.0.1:0
ssh -X marko@vm

Or if you're using cmd.exe:

set DISPLAY=127.0.0.1:0
ssh -X marko@vm

When you run ssh -X remotehost and you get DISPLAY=localhost:10 presented to the remote host. ssh listens on that port and forwards traffic back to the calling system, using its original value of DISPLAY to determine the server address.

It's probable that on your local system you've got DISPLAY=:0. Or if you haven't, that's what it's being defaulted as. This instructs the local system to use the UNIX domain socket to communicate with the display. Unfortunately Xming on Windows doesn't set up that UNIX domain socket so your ssh X11 forwarding fails with this sort of error:

$ export DISPLAY=:0
$ ssh -X remotehost xlogo
connect /tmp/.X11-unix/X0: No such file or directory
Error: Can't open display: localhost:10.0

The fix - at least as far as Xming goes - is fairly simple. Modify the DISPLAY variable to reference a listening TCP socket rather than a UNIX domain socket.

$ export DISPLAY=localhost:0
$ ssh -X remotehost xlogo

You might have to adapt your Xming configuration to listen on the local TCP port 6000. Here is how I start Xming:

Xming.exe :0 -clipboard -multiwindow

And here is evidence to confirm that Xming is listening on port tcp/6000:

$ netstat -na | grep ':6000 .*LISTEN'
  TCP    0.0.0.0:6000           0.0.0.0:0              LISTENING

This work for me: Set environment variable in PowerShell:

$env:DISPLAY="127.0.0.1:0"

Then ssh -Y

Tags:

X11

Ssh