How do I... run Linux applications in Windows XP?

Jack Wallen explains how to set up a remote connection between a Microsoft Windows PC and a Linux PC using X tunneling.

Linux-to-Linux remote application viewing is simple: Use secure shell with the -X switch to tunnel X from one machine to the other. Linux to Windows isn't as simple because, without help, Windows has no way of rendering X applications on the desktop. Fortunately, there are ways to do this.

There are many reasons why an administrator would want to be able to run Linux GUI applications from a Windows machine. Say, for example, you have a GUI-enabled Linux server that you run headless. Instead of attaching a monitor, you can just log in from your Windows machine and run the Linux application. It's not really that difficult. Let's see how it's done.

This blog post is also available in PDF format as a TechRepublic download.

What you will need

There are a couple of ways to handle this task. The first is with XWin32 and PuTTY. The second is with Xming with Portable PuTTY and PuTTY. Although PuTTY and Portable PuTTY are both free, Xming is available only via donations (you receive a log in when you donate). And XWin32 licenses are based on seats and use. The cheapest XWin32 license is a student license at $69.99. We are going to demonstrate this task with the PuTTY/XWin32 combination, because that is the most corporate-friendly method. You can, of course, download a limited demo of XWin32 that will time out at 30 minutes for each session.

Getting and configuring PuTTY

PuTTY is one of the most popular Windows SSH clients available. It's free and just as secure as its Linux counterpart. You can get the putty.exe file from the official site download page. Once you download PuTTY, you will have an executable file (it is not an installer).

When you run PuTTY you will see a fairly simple interface. There are just a few configurations you have to take care of in order to set up your Windows system for X tunneling. The first thing you need to do is open up the PuTTY application where you will see the window opened to the Sessions portion of the configuration (Figure A).

Figure A

Remember to save your sessions or you will wind up having to reconfigure your session each time.

The first thing you need to do is enter either an IP Address or hostname in the Hostname configuration option. Once you have done that, make sure the SSH connection type is checked. Now you can either save this under Default Settings or create a new session.

If you know you are going to connect to various servers, it's best to leave default settings alone.

Once you have given your session a name, click Save. Now, expand the SSH section in the left pane to reveal the X11 option. You need to check Enable X11 Forwarding and enter "localhost:0" in the X Display Location section (Figure B)

Figure B

The default MIT cookie should work for most SSH sessions.
Once you have taken care of X11, go back to the sessions section and click Save again. As you can see in Figure C, I have given my session the name "monkeypantz" and saved this session.

Figure C

Now the "monkeypantz" session is saved with your configurations.

If you double-click "monkeypantz" a new command window will open, connecting to your remote SSH server. You will be prompted to accept (or reject) the SSH key from the server. You must accept that key to continue. Once the key is added, you will be prompted for a username and password. Once you enter the username and password, you will wind up at your Linux bash prompt almost ready to launch an X-tunneled application.


NOTE: The newest version of XWin32 (called XWin32 Live) doesn't require the additional installation of PuTTY because it has SSH built in to the system.

On top of that the new XWin32 Live doesn't require a large X Windows instance to be open underneath your UNIX/Linux application, so the desktop has much less clutter when an X Windows application is open on your Windows desktop. Starting an X Windows instance is done in the same way as it was in earlier versions: you simply right-click the XWin32 icon in the system tray and select the session you want to start. At that point the only window that will open is a command window with your Linux bash prompt.

Editor's Note: Jack Wallen is writing a new blog post to explain the improvements found in this new version.


Getting and configuring XWin32

The next step is to download XWin32. You have to fill out a form after which you will be sent a download link as well as a trial license number for the software. Once you have the file downloaded, double-click to install it.

Now that XWin32 is installed, you have to do a bit of configuring. If you go into the Programs menu you will notice a new entry for XWin32. From there choose the XConfig option, which will open the configuration window. The simplest way to set up your connection is to use the Wizard button. Click the Wizard button to start the process.

The first configuration step is the Connection Method. You have three choices: rsh, rexec, and XDMCP (Figure D). The XDMCP is what you want to choose. Click XDMCP and click Next.

Figure D

XDMCP is the X Display Manager Control Protocol.
The next step is to select the XDMCP Broadcast Mode (Figure E). Here you want to select Query (since you know the host or IP address of the server.)

Figure E

If you have no idea what the host or IP address is you can select Broadcast, which will scan for available SSH servers.
The next step is to enter the host name (or IP address), as shown in Figure F.

Figure F

Either host name or IP address will do the trick.
The final step is to name the session and finish the configuration (Figure G).

Figure G

You can automatically launch the new session by checking the Launch This Session Now box and clicking Finish.

Fire it up

Now that you have both PuTTY and XWin32 configured it's time to fire up a session. If you closed PuTTY, fire it back up and log on to your server. Now go back to the Programs menu and then to the XWin32 submenu. From the XWin32 menu select X-Win32. You will notice a small "X" now in your system tray. From that small X you can select which session you want to connect to via a right-click. Selecting the session you want will open up an X Windows session (Figure H).

Figure H

When the XWin32 window opens, it is full screen, so you have to minimize it to get it out of the way.
Now go back to the PuTTY window where you are logged in to your Linux SSH server. From this prompt, enter the command to start up the application you want to run. As you can see in Figure I, I have Kopete running in the XWin32 window.

Figure I

As you can see, the window manager is not present, so windows cannot be moved around.

I have managed to get KDE running in an XWin32 session. What is odd about it is that the Kicker opens in one window and the desktop opens in another. Normally you wouldn't want an entire Window manager or desktop running in this instance, but there are times when it could come in handy.

Final thoughts

The ability to tunnel X Windows applications into a Windows box has limitless possibilities for administration purposes or even for end-user work. This only serves to boost possible productivity in Windows by expanding the tool selection available into the realm of UNIX/Linux.