Cygwin via Citrix or Terminal Server

One of the worst things about working in IT is logging into many computers. In IT, computers that aren’t 100% under your control as a programmer or administrator often don’t have the tools you are used to. Worse, often you aren’t supposed to install extra software on these computers. After all, they might be production servers!

Citrix MetaFrame and Microsoft Remote Desktop(Terminal Server) both support mounting your desktops local drives to the remote system. In my case, Citrix was doing it by default. I connect and the v: is actually the c: on my laptop. I have cygwin on my c:\cygwin directory on the laptop. The normal way the cygwin bash prompt is invoked is via the cygwin.bat script. This script makes some assumptions that aren’t true in a MetaFrame/Terminal Server environment. Invoking this script directly on the remote server won’t work, but here is a work around.

Run bash.exe directly via cmd.exe. To do this, launch cmd.exe, then run bash by calling its full path, which is now v:\cygwin\bin\bash.exe. Once you do this, you will have a bash prompt, but you will immediately notice that “nothing works”. Well, somethings do work, and with a little more configuration you will have a fully functional cygwin.

Run /cygdrive/v/cygwin/bin/mount and notice that the normal /, /usr/bin, and /usr/lib are not mounted. Mount them by running these commands:

/cygdrive/v/cygwin/bin/mount -f c:/cygwin /
/cygdrive/v/cygwin/bin/mount -f c:/cygwin/bin /usr/bin
/cygdrive/v/cygwin/bin/mount -f c:/cygwin/lib /usr/lib

Now your mount points will be set, but you will notice that your path doesn’t include the usual /usr/bin, /usr/local/bin, etc. No problem, just restart the bash shell.

exec /usr/bin/bash --login -i

Now you will notice you get your pretty prompt, and a note about /etc/passwd and /etc/group. I don’t go to the trouble of configuring the /etc/passwd and /etc/group files, so just ignore the instructions to run mkpasswd.

Next time you want to start cygwin, you won’t need to follow the mount steps, just run cmd (or start->run), and then v:\cygwin\bin\bash –login -i.