Ssh – Is it possible that X11 can be forwarded through a SSH tunnel

sshwindowsx11xforwarding

I communicate with the server via a ssh tunnel, configured via Putty.

Recently, I'm trying to forward the X11 through it, but it doesn't work.

Is there any one work this way?

Searched with google, but didn't find anything.

Best Answer

Yes, this is possible in a few different ways but you will need an X window server for Windows. Some options of a X windows server are XManager, XMing and MobaXterm. Once you have an X server running on Windows you can use PuTTY to connect to your host after you have set the configuration parameters:

Connection/SSH/X11
  Enable X11 forwarding
  X display location: localhost:10.0

Where the 10.0 depends on what the X Window server is listening on.

When you configured the X Window server and PuTTY and logged in to your host you can verify the DISPLAY variable if a DISPLAY is set:

$ echo $DISPLAY
localhost:10.0

Then try something like xclock to see if X11 forwarding works:

# xclock &

Another way to use X11 apart from ssh is to set the DISPLAY variable manually to point to an IP address like:

# export DISPLAY=192.168.0.1:0

And see if it works:

# xclock &

This way X applications are (re)directed to output to a remote X Window server.

Note: Keep in mind that the X11 protocol is not designed to operate over slow network (WAN) connections. The X application may be terrible slow when used over slow connections. Consider to use the -C (compression) switch with ssh to use compression over the ssh session to speed it up a little.

Related Question