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

25,647

Solution 1

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.

Solution 2

Hi if you want to use the putty like use Openssh with -x you have to install XMING on your windows machine . it became like some sort of server then you have to config you putty to forward X11 of you ssh connection over this server

Download Xming

You can use this tutorials

Solution 3

Yet another solution is to install Cygwin on your Windows machine. It has both ssh client and X11 server (be sure to install the corresponding packages).

Keep in mind that many X11 installations forbid untrusted X forwarding. Perhaps the simplest way around this is to use -Y option in ssh

ssh -Y user@server
xclock
Share:
25,647

Related videos on Youtube

sleepy
Author by

sleepy

Updated on September 18, 2022

Comments

  • sleepy
    sleepy over 1 year

    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.

    • Naftuli Kay
      Naftuli Kay over 8 years
      With regular OpenSSH, you should be able to pass the -X flag and X forward, but I'm not sure how that would be accomplished over a TCP port.
    • Jonathan Ben-Avraham
      Jonathan Ben-Avraham over 8 years
      If you are using PuTTY does that mean that the host from which you are connecting to the server is running MS Windows? If so, then you would need an X server running on Windows that is configured to accept TCP connections.
    • Deb
      Deb over 8 years
      You wrote 'it doesn't work'. In future questions, please explain in what way it doesn't work: what you tried, what error messages you see, what relevant log messages, and what behavior you saw.
    • Ismael Miguel
      Ismael Miguel over 8 years
      If you are using Debian, take a look at: superuser.com/a/862647/391087
  • rackandboneman
    rackandboneman over 8 years
    Small wording issue there: What he needs is an X Window server. A window manager would usually be included in such an installation, but isn't 100% necessary, and could even be run on the remote machine.
  • rackandboneman
    rackandboneman over 8 years
    XMING is one good solution, but not the only one.
  • chrishollinworth
    chrishollinworth almost 6 years
    Just like the terms "client" and "server", be careful of the terms "trusted" and "untrusted". A "trusted" connection is one where several of the usual security controls are disabled - i.e. you trust the system you are connecting to not to bad things to you.