Connect to remote Unix desktops with Cygwin

871

Author: Avinash Parampalli Vasudev Aithal

In my work I’m expected to be on a Unix system 80% of the time, yet I also need to use office applications, a Windows-only VPN client, and some Windows-based asset management tools. That leaves me with little choice but to use a tool to connect a Windows client to a remote Unix desktop. I could use a terminal emulator or connect via a VNC server, but I’ve found that Cygwin, a Windows port of many GNU/Linux tools, is the best way for me to bridge the gap.

Cygwin brings a Unix-like desktop environment to a Windows PC. For example, it can be used to run a bash shell with a Unix-like terminal in Windows. It also helps to access the complete desktop environment of a remote Unix machine. To give you an example, you can customize a GNOME session, including the screensaver, and you even get those bang sounds that play when you press an invalid key in a vi session.

Installing Cygwin is pretty straightforward. Download the setup.exe program from the Cygwin Web site and run it. It will help you choose what to download, manage downloading your choices, and install all the components. A quick-and-dirty method is to choose all the components under category X11 when the script prompts you to select packages.

Once the installation is finished, you’ll find a batch file named startxdmcp.bat under the $CYGWINHOMEusrX11R6bin directory — $CYGWINHOME being the top-level Cygwin installation directory, which is prompted by the setup.exe script before even downloading the packages. You’ll want to edit the batch file and make two changes.

First, change the REMOTE_HOST value to your server’s IP address, then look for a line like run XWin -query %REMOTE_HOST% -nodecoration -lesspointer :1. Add the option -clipboard as one of the parameters (if it’s not already present); this will allow you to copy text from a GNOME terminal in the Cygwin window and paste it into Windows application running locally on your PC. Make sure make sure an xdm server is running on your target host, then run the batch file to launch a connection to the remote xdmcp server. In Linux, it is as simple as typing xdm at the console. For advanced xdm options, refer to xdm’s man pages. Then, log into your *nix desktop normally.

There’s a lot to like about Cygwin. For one thing, it’s amazingly lightweight. An instance of Cygwin takes just about 8MB of system memory on my Windows 2000 PC, a Pentium 4 with 256MB RAM. It’s also stable — I’ve been running it for more than six months and it’s never crashed on me. And of course, it’s free.

Cygwin allows a great deal of customization in installations and utilities, and it’s easy for organizations to customize it to meet their needs. Folks in my organization use Cygwin as a terminal, specifically to access mainframe computers.

Cygwin is a pretty hefty download, about 150MB, but this is justified for the a package which contains the entire X server along with all the Unix tools like shells, GNU utilities, etc. Also, given network speeds these days, this may not be a big issue, but I didn’t like waiting two or three hours to download and install the software over my cable Internet connection.

Cygwin has helped me get the best of both worlds — the developer-friendly Linux environment on a user-friendly Windows laptop.