Home > Web Development > Using PuTTY and Xming for X11 Forwarding

Using PuTTY and Xming for X11 Forwarding

The X Window System, or X11, is the window server for Linux. If you’ve used a desktop Linux distribution like Fedora or Ubuntu, you’ve used X11. Desktops like GNOME and KDE are displayed by X11. Programs that you open on a Linux desktop are displayed by X11.

Usually, when you want to connect to your Linux computer from a remote location, you do so with SSH (Secure Shell). SSH lets you make a secure terminal connection to your Linux computer and use the command line. But, wouldn’t it be cool to connect to your remote Linux computer and use its fancy graphical interface? This tutorial will show you how to connect to a remote Linux computer from Windows and use the X11 graphical interface using two free programs, PuTTY and Xming.

PuTTY

PuTTY is a free SSH client that allows you to connect to a remote Linux computer and use the command line. PuTTY can also be used to forward secure data over SSH to other programs. This is called tunneling. We’re going to be taking advantage of PuTTY’s ability to tunnel X11 data. To do that, we first need to install PuTTY.

Installing PuTTY

  1. Download putty.exe to your Windows desktop from the following address:
    http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html
  2. There is no installer. Putty.exe is a self-contained executable program. Put it someplace you can easily find it, and make a desktop shortcut to it if you like. I usually put it in C:\Program Files.

Creating a PuTTY Session to Connect to Your Remote Linux Computer

When you connect to your remote Linux computer, you will need to set several connection settings to make everything work correctly. PuTTY lets you save these settings in a session so you can reuse them the next time you connect. We’ll make a session that allows PuTTY to forward your Linux computer’s X11 graphical interface over SSH.

  1. Open PuTTY on your Windows desktop.
  2. PuTTY will open and display the Session panel.
    1. In the Host Name field, type the hostname or IP address of your Linux computer.
    2. In the field underneath the Saved Sessions label, type a name for your saved session.

    PuTTY Session Configuration Screenshot

  3. Under the Connection category, expand SSH and choose X11.
    1. Click the Enable X11 Forwarding checkbox.

    PuTTY X11 Forwarding Screenshot

  4. Go back to the Session category and click Save to save your session connection settings.

Xming

Xming is a free X Window server for the Windows desktop. With Xming, you can display graphical applications from your remote Linux computer on your Windows desktop. To take advantage of Xming’s capabilities, we’ll need to first install it.

Installing Xming

  1. Download the Xming installer to your Windows desktop from the following address:
    http://www.straightrunning.com/XmingNotes/
  2. Look for the Xming link under Public Domain Releases.
  3. Run the Xming setup program on your Windows desktop. When selecting components to install, make sure the following are selected:
    1. XLaunch Wizard (selected by default)
    2. Normal PuTTY Link SSH Client (selected by default)

Running Xming

The makers of Xming have provided a simple utility called Xlaunch that allows you to configure Xming easily, and also save your configuration for future use. To run Xming, open XLaunch and select the configuration you wish to use. We’ll use the configuration that follows.

  1. Open XLaunch from the program menu.
  2. Select Multiple Windows and click Next. This tells Xming to open each remote Linux application in a new window.
    XLaunch Multiple Windows Screenshot
  3. Select Start No Client and click Next. This tells Xming to launch and wait for commands from another program (like PuTTY).
    XLaunch Start No Client Screenshot
  4. Make sure that Clipboard is selected and click Next. This tells Xming to enable your remote Linux applications to share a unified clipboard.
    XLaunch Clipboard Screenshot
  5. Click the Finish button to launch Xming.
    XLaunch Finish Screenshot

Launching Graphical Applications from your Remote Linux Computer

Now that Xming is running, you can open your PuTTY session and launch a graphical application. My Linux computer is running Fedora 12 with the Gnome desktop. I’m going to launch my remote Linux computer’s calculator on my Windows desktop through the SSH connection using X11 forwarding.

  1. Open PuTTY.
  2. Double-click on the saved session you created earlier. PuTTY will create an SSH connection to your remote Linux computer.
    Launch PuTTY Screenshot
  3. Login to your Linux computer.
  4. Type gcalctool at the command prompt and hit enter.
    Launch gcalctool Screenshot
  5. If everything worked correctly, your remote Linux computer’s calculator should appear on your desktop. Cool, huh?
    gcalctool Screenshot

If you have any questions, please feel free to ask in the comments section below.

Nate Smith Web Development , , , , , ,

  1. | #1

    What do you mean “Windows already has a perfectly good calculator?”

  2. Fred Hillebrandt
    | #2

    Thanks for making this information available. It was very helpful to me.

    Fred

  3. Slash
    | #3

    Hello,

    thanks for your tutorial.

    When I try to run something after doing all steps in your tutorial I get the following error:

    Error: Can’t open display:

  4. | #4

    Which Linux distribution and version are you trying to connect to?

    Also, check out these troubleshooting tips: http://www.straightrunning.com/XmingNotes/trouble.php

  5. ali
    | #5

    how to start startx

  6. Denis
    | #6

    Thanks, man. It was helpful

  7. brittany
    | #7

    what if you want more than just a calculator? you want all of xming environment to show? help please!!!

  8. Ben Weaver
    | #8

    Excellent tutorial!! I work in IT, I am a programmer, in fact, and 9 out of 10 Xll tutorials provide way too much information or use terms like ‘Display’ maddeningly without defining which computer they might apply to. This is the 10th. You define the use-case many people want without a lot of pretentious generalization:

    This tutorial will show you how to connect to a remote Linux computer from Windows and use the X11 graphical interface using two free programs, PuTTY and Xming.

    You explain without waiver the roles played by XMing:

    ‘Xming is a free X Window server for the Windows desktop.’

    Yes, XMing is a SERVER–even though it resides on windows. So, from your clear language I can infer that an x-augmented ssh session goes like this:
    linuxbox ———>XMing which serves up the remote linux data on the windows box. If the windows box is an ssh client, fine, you can say that, but this windows client, after consuming remote linux data, supplies it to its local xserver, which serves it to the windows display. XMing is a server even though it is local.

    At least that’s the way I understood it. In any event I had a session up in 5 minutes following these instructions. Well done.

  9. | #9

    Ben, thank you for the kind words! I’m glad the tutorial was useful.

  10. | #10

    Brittany, if you want to see your entire Linux desktop, you’ll want to use VNC. You can install a VNC server on your Linux server, then use the RealVNC client on Mac or Windows to view your Linux desktop. Sorry I didn’t see your comment until now.

  11. Cameron
    | #11

    Thank you! I had been working for days trying to configure Cygwin/X-Win32/PuTTy. I found your site and had xclock working in minutes. Saved me an F in a Java course!

  12. | #12

    Cameron, I’m glad it helped!

  13. Tata
    | #13

    Awesome.. Thanks..

  14. | #14

    Tnx for the post. BTW: for my error “Can’t open display” on Fedora 15 it helped to install xorg-x11-xauth and dbus-x11 packages by yum.

  15. | #15

    EDIT: absence of the dbus-x11 was causing “Could not connect to session bus” error.

  16. Biju Parayil
    | #16

    Thank you. This was very helpful for me. Great job!

  17. trevx03
    | #17

    Thanks a lot. Really helpful and clear tutorial.

  18. pragnesh
    | #18

    Hi,

    i m not able to config xming . i want to install content server

  19. Agg812
    | #19

    many thanks MAN! That works exactly as described. Great post!

  20. William
    | #20

    Thanks so much for putting together such complete, clear and well organized documentation. Intelligible descriptions, screen shots, links, it’s all here.

  21. | #21

    Thanks for this. I just spent ages trying to figure it out and you’ve sorted me right out.

  22. | #22

    Hello my Name is Antonio and I depart in Padua (Italy).My compliment for content material.I read yours posts.I advise you 1 visit. Thanks.

  23. Uma
    | #23

    I was able to get the gui, using putty and xming. But I stopped TCP6 connections. Now I cannot get the gui. When I run the command startxfce4, I get

    X: user not authorized to run the x server, aborting.
    No protocol specified.
    No protocol specified.
    xint: giving up
    xint: unable to connect to x server: Resource temporarily unavailable.
    xint: server error.

    please give me a solution as soon as possible…

  24. | #24

    Thanks for the help !!!

  1. | #1