Home > Linux > Use xming, xshell to display linux gui to windows desktop (x11 forwarding)

Use xming, xshell to display linux gui to windows desktop (x11 forwarding)

May 24th, 2011


Firstly, download xming, install it on your windows pc system.

You can go to http://sourceforge.net/projects/xming/files/ to download.

Let’s assume that you want to run xclock on solaris/linux server 192.168.0.3, and want the gui display on your pc whose ip is 192.168.0.4.

After installation xming on your windows, log in linux/solaris server 192.168.0.3. Set environment variable DISPLAY to the ip address of your windows, and append a :0 to it:

#export DISPLAY=192.168.0.4:0

Then you must allow X11 forwarding in sshd configuration file. That is, set X11Forwarding to yes in /etc/ssh/sshd_config and restart your sshd daemon.

After this, you need set 192.168.0.3(linux/solaris) to the allowed server list on your windows. Edit X0.hosts which locates at the installation directory of xming(For example, C:\Program Files\Xming\X0.hosts), add a new entry in it:192.168.0.3, the ip address of linux/solaris that you want to run x11 utility from.

Note: Thanks to linuxdict.com :D

Then, restart xming on your windows. And on solaris/linux server(192.168.0.3), run a X11 programe, like

#/usr/openwin/bin/xclock &

You will then see a clock gui pop up in your windows pc.

Amazing, isn’t that?

PS: Something from xshell x11 faq:(Actually, this step is not necessary to our goal)

Q:How do I run the X11 applications through Xshell?

X11 forwarding is a bit different from other TCP/IP port forwarding.
Please, go through the following steps.

  1. To enable X11 forwarding service in Xshell: On the Tunneling tab of Advanced SSH Options dialog box, check Forward X11 Connections To. and select Xmanager if Xmanager is installed in your PC. If you use another PC X server, select X Display Location and enter the proper display name.
  2. To enable X11 forwarding service in the SSH server: Setup the configuration file in the following table.
    SSH server Config file Setup
    OpenSSH /etc/ssh/sshd_config X11Forwarding yes
    SSH.COM /etc/ssh2/sshd2_config AllowX11Forwarding yes

  3. To run X11 applications from the Xshell terminal:
    1. If Xmanager is installed on your PC, just go to the next step. Otherwise, run the PC X server installed on your PC first.
    2. Start the SSH connection with the session enabling X11 Forwarding.
    3. At the shell prompt of Xshell, execute the X11 applications like the following examples:[nathaniel@intranet ~]$ xterm &
      [nathaniel@intranet ~]$ startkde &
      [nathaniel@intranet ~]$ gnome-session &

Categories: Linux Tags:
  • Pingback: "Can't open display" Error when running X applications remotely

  • Tom Tobin

    Thank you, from the bottom of my heart. I have been trying to get this to work for a couple of days now, from bits and pieces scattered all over the net.
    This is the first cohesive posting I have seen, that made everything work.
    It’s much appreciated!!!

  • Casolisco

    Great!
    =)
    Thnx a lot!!

  • Wtrnymph

    This is an absolute guide…I had to murk thru quite a bit before I got it. Thank you so much!

    • doxerorg

      Glad this helped, good luck!

    • doxerorg

      Glad this helped, good luck!

  • Jayesh

    I did this, everything works fine except clipboard.
    I cannot copy text from xming (say gvim opened in xming) to xshell window, but I can copy it to any other windows application like msword. Please let me know how to fix this.

  • HS

    Amazing.. Worked like a charm !! Cheers..

  • Abhinav

    I am creating a GUI in java swing on linux client machine which creates a ssh connection to the remote linux server on button click and execute a command “java -jar GUITest.jar”, But i am not able to see the GUI of GUITest.jar. I am using Jsch library for SSH connection.
    Same thing i am able to do in windows,i have used same java code and there i am running Xming server which opens GUI automatically on client machine but the application actual runs on server. please provide me the solution.