Installing Cgywin/X on Windows to remotely control (over SSH) a Linux server

Introduction

I work at company that is mostly a Windows/Intel shop. As a rule, we only always Windows unless a particular solution is not available for the Windows platform. We recently installed such a solution. The system administrator said that he had to be able to connect to the Linux desktop so he could manage it. He said that he could not manage the solution from the command line. Always looking for a challenge, I took it upon myself to find a working solution.

I have worked with Exceed from Hummingbird before. Nice software, but very expensive. In typical fashion I ran a Google search to find a free solution. The first hit was for Cygwin/X. After studying their site, it decided it should satisfy our needs.

As is often the case with Linux related solutions, documentation is rarely complete and difficult to find. Because I was doing this for work, I documented the process for the desktop support guys. The installation wasn't too terribly difficult and the end result is very usable. What made this installation more difficult was configuring it to run securly via X11 forwarding AND the requirement to disable the standard X11 ports.

If you find yourself traveling down this same road, you might find this document helpful. If you don't find it helpful, just remember that it didn't cost you anything!

Part 1: Installing Cygwin/X for X windows support on Windows XP

1.Run or download Cygwin/X installer from http://cygwin.com/setup.exe

2.Select "Install from Internet".

3.Make the Root directory "c:\cygwin"

4.Choose either Install for "All Users" or "Just Me"

5.Default Text File Type should be "Unix / binary"

6.Select a download mirror site from the list. Keep in mind that the official Cygwin sites are usually very slow.

7.
At the "Select Packages" dialog box, click on the "View Full" button (near the top right of the dialog box) and select the following packages. Other packages may be auto-selected as part of the base installation. That's ok. Do not deselect any of those packages.
ash
cygwin
fontconfig
freetype2
jpeg
libart_lgpl
libaspell15
libbz2_1
libiconv
libpcre0
libsasl2
libtiff5
libxml2
libxslt
openssh
openssl
rebase
xorg-x11-base
zlib
*Note: If the installer loses connection with the mirror site you selected, it will return you to the mirror site selection window. Simply select a different mirror site. The packages you selected previously will remain selected.

8.To test connectivity to a remote Linux server, click on the Cygwin icon (desktop or Start | All Programs | Cygwin | Cygwin Bash Shell). The first time you run it, you will see some messages about copying files. This is normal. At the command prompt ($) type:

X –query [host] –clipboard

This command will not work after you have restricted direct connectivity to X11 on the server later on in this document. The “-clipboard” option allows you to cut and paste between your Windows computer and the Linux server.

9.When you log out, the X window will return to the login screen. To close the connection to the remote Linux box, you can either click on the “X” button in the top right corner or hit [Ctrl] + [C] in the Cygwin Bash Shell window.

10.Download the PuTTY SSH client from http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html Place it some where convenient, as you will have to start it after you start Cygwin/X.

*Note: SecureCRT will also work with the setting mention above, but PuTTY is free. I recommend PuTTY unless you need the advanced feature of SecureCRT.

11.Enable X11 forwarding in PuTTY
Navigate to the X11 page and:
a. Place a check in the box next to “Enable X11 forwarding”
b. Click the radio button next to “MIT-Magic-Cookie-1”

12.To save your settings:
a. Click on Session in the left category window
b. Enter a name for your session in the Saved Sessions box
c. Click on the “Save” button on the right

Part 2: Configure Red Hat Linux server to allow remote connections

1.Verify that OpenSSH is installed and working correctly on the remote Linux server.

2.Verify /etc/X11/xdm/xdm-config
For SSH only access set to:DisplayManager.requestPort: 0
For unsecured X windows access set to:!DisplayManager.requestPort: 0
*NOTE: As of 10/28/05 there is a know vulnerability in the XFree86 code that ships with Red Hat ES 3 (and possibly other versions) that ignores the setting above.

3.Edit /etc/X11/xdm/Xaccess
Change:#*#any host can get a login window
To:*#any host can get a login window

4.Edit /etc/X11/xdm/kdmrc - if present
Under the [Xdmcp] section heading
Change:Enable=False
To:Enable=True

5.Edit /etc/X11/gdm/gdm.conf – if present
Under the [Xdmcp] section heading
Change:Enable=False
To:Enable=True

Part 3: Connecting to remote Linux server

1.Start Cygwin

2.In the Cygwin window type: X –clipboard

3.Start PuTTY and connect to remote Linux server

4.In PuTTY terminal window type: startkde
The KDE desktop will start in the X Window that was created in step 2. Because you entered your username and password in using PuTTy, you will not be asked for a username and password when the KDE desktop appears. This is fine. The Red Hat server already authenticated you.