Linux

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.

About

Jack Wallen is an award-winning writer for TechRepublic and Linux.com. He’s an avid promoter of open source and the voice of The Android Expert. For more news about Jack Wallen, visit his website getjackd.net.

21 comments
dold
dold

Why cobble together a solution from different vendors, some of them shareware? http://cygwin.com offers XFree86, ssh, bash, and a lot of other GNU utilities that make Windows a very Linux-like command line experience, and offers X. I run X applications from a variety of Unix boxes, via ssh tunneling or direct, via CDE, KDE, Gnome, and individual X-windows.

me.g33k
me.g33k

Now about XLiveCD? It uses the Cygwin stuff but it works quite well when I have to use X-Apps on my windows desktop. Also I just keep the ISO file and mount and run it as an image when needed so I don't need to have additional 'cruft' on the host system.

rkuhn040172
rkuhn040172

Remote connections or sessions to a Windows box has been so easy for so many years. RDC, enter IP and away you go. Why so complicated for Linux?

Mark W. Kaelin
Mark W. Kaelin

Jack explains how to use X tunneling to create a secure remote connection between a Windows and a Linux PC. Do you find this sort of setup to be more common than a few years ago?

radbam
radbam

Don't get me wrong ; StarNet puts out some really good products, e.g., X-Win32[Flash], ReconX and StarNetSSH , and well worth the price...if you can get Corporate to spring for it. But if you have to "poor boy" it, CygWin can't be beat for SSH, X, "pick-your-Shell", etc. Just remember to grant minimal Write privilege to login user to run X on the M$ box. Haven't found a better AND less expensive solution ("Free As In Water", right).

Neon Samurai
Neon Samurai

I use Mandriva One liveCD to make my work issues notebook native to my home network. It becomes a thin client running all my applications off my desktop when I'm anywhere else in the house. With VMware I can mount an ISO liveCD and boot it up under Windows. On the other side, I just boot Windows inside a VM when I need that platform specifically (some of my security tools require win32).

Neon Samurai
Neon Samurai

The Point here was how to get a remote desktop on your Windows platform tied into a Unix like platform on the other end. Your dealing with cross platform. From Linux to Windows, rdesktop and vnc work just fine and as easily as a Windows to Windows connection. From Windows to Linux for those who can use the shell, ssh is dead simple and seamless across platforms. If Windows included an X server like every other modern OS then it would be completely native and simple also. Really, the most simple setup is just to drop a VNC server on your remote Unix like server and use the Windows terminal server client or win32 VNC client to connect. I personally just use the applicable local platform to connect to the applicable remote platform. Luckily for me, that's a Unix like local platform as I can connect simply too both Windows and Unix like remote systems. Maybe the question should be; why so complicated for Windows?

jlwallen
jlwallen

if you're doing this linux-to-linux it is a piece of cake. but we're talking about opening Linuxs apps in Windows. the difficulty comes because the Windows GUI doesn't contain any of the widget sets and tool kits that allow opening Linux apps. because of that you have to be able to tunnel not only the app but the wiget as well. if you are doing this windows to windows it's easy because windows already contains everything it needs to run windows applications.

jaguar11735
jaguar11735

Cygwin-X is free, yes, but has been without a maintainer for three years. XMing releases their older versions for free (open source). You only have to 'donate' for the newest release.

jvc
jvc

.. And then install a virtual linux there. Give i a NAT connection to it virtual network. Then just do what ever linux things from there. When done you can even copy the linux-image to other PC's virtual enviorments

dold
dold

I find tunneling very common. A lot of shops have firewalls that block most ports. The normal X-users, if there are any, are in the local LANs, but any remote support access has to traverse firewalls that admins are unlikely to open in an enterprise configuration.

pgit
pgit

I've found xming and copSSH to be the easiest and best app for their respective tasks. Almost no configuration required. Best of all they are both being maintained. cygwin... don't get me started. But copSSH installs/configures exactly what you need out of that mess and nothing more. Try 'em, you'll not believe how easy this is...

Neon Samurai
Neon Samurai

I was trying to setup this or something similar with portablePutty and a portable app version of Xwin32 or a similar X server on Windows offering. I'll be reading through this in detail later to see what it was I missed the last time around though. In general, I use a native Linux based OS boot or VM and ye' old ssh/X. I have a remote admin who's more comfortable in Windows still so I've got him using a VM when needing to forward X applications over the network.

rkuhn040172
rkuhn040172

So what you're talking about here (sorry for my lack of experience on this topic) isn't merely just opening up a terminal session. What your talking about is more like streaming an app?

dold
dold

Wow! I hadn't noticed, but now that you point it out, all of my Cygwin /usr/X11R6/bin is from 2005. Maybe there are no bugs ;-) The rest of Cygwin receives regular updates.

cwmoser
cwmoser

Definitely NoMachine - aka NXServer, FreeNX, etc. NoMachine application is vastly superior to anything I have used including VNC, RDP, putty, ssh, telnet, etc. I use NoMachine to remote into my Linux home PC to run QuickBooks, Quicken. CrossOver is great for running Windows Apps on your Linux OS. I see a trend to a blurring of OS's where the OS is a perference rather than a necessity. For example, I prefer Linux for a lot of reasons and I still run various Windows Apps on my Linux PC. Sorta a la carte rather than being forced to select the Microsoft Combo from the menu listing. Carl

Neon Samurai
Neon Samurai

I see it in a few ways depending on the way one chooses to do it. With SSH/X forwarding, it would be streaming an application. The program runs on the remote system. It used the remote resources (network card on remote take the load if your downloading from the web, sound on the remote pumps out the music if you play a sound file). The display of the program is rendered on your local screen and your input by mouse and keyboard are forwarded too the remote system. Cygwin and XWin32 are both X servers that run under Windows. (with X, the server is the local program that displays the GUI) This is pretty much the same as a native Xwindows to Unix connection and works like the point above except that you have the cygwin layer between Windows and the remote application. With VNC, your doing desktop sharing in the more classic form. This is like using Terminal Server client in that the programs run on the remote system but you get forwarded a frequently updated image representing your desktop with your input being forwarded back to the remote server based on what clicking and typing you do within the desktop image. The alusion is that you have a local desktop projected from the remote system.

Neon Samurai
Neon Samurai

Is it a stand alone server setup or do you have to run it through a third party like "gotomypc"?