Here’s a quick tutorial to run an X server on your windows laptop/desktop so you can run remote X-apps from a remote linux/unix server.
The common way to do this is using vncserver on the remote linux/unix machine and a vnc client on your windows desktop. That is definitely the easiest way too, especially if you want the full desktop itself.
However, sometimes this is not feasible. If you need to run an X application on a remote server that does not allow vnc ports, then what?
Or what if you need something more secure? VNC traffic is NOT encrypted so it’s possible to snoop the passwords out
You can run an X server on your windows laptop/desktop and then run X-apps from the remote machine. And the good news? It runs over the SSH port 22 so all traffic is encrypted!
WAIT …. WHAT IS CYGWIN?
So let’s back up a bit
Cygwin is an application (a very large one) that lets you run linux/unix commands on your windows. It opens up a shell and lets you type commands. What commands? There are a large number of software packages you can choose to run, and I recommend you go through them and choose. For linux admins using windows as their desktop/laptop, it is like being a kid in a candy store!
Package list is here:
WAIT ..WHAT IS CYGWIN_X?
Cygwin-x is just Cygwin, but denotes that you have installed the X server with it. Don’t let it confuse you. It is not a separate application. It just means you installed X with your Cygwin. Because it is a bit more detailed in its install as you need to select the packages individually (there is no checkbox to just say “Install X server”) the Cygwin people created separate instructions and a separate page for Cygwin-x
Also if you’d like, directions from Cygwin are here (for full install including X-server):
But I’ll walk you through it below too:
Here is the Cygwin download link (also found on the main Cygwin page and Cygwin-x page)
NOTE: the install executable for Cygwin and Cygwin-x are the same!
Why install Cygwin?
Cygwin (of which Cygwin-X is a part of) has a lot of handy linux/unix utilities you can run from a windows laptop. I use these a lot, both as a sysadmin and as a user
Some things you might find useful:
find and grep (I still can’t get the hang of Windows 7 searching)
gcc and other compilers
Also you can use ssh-keygen for ssh/RSA authentication to your favorite linux/unix boxes. (I will admit most of the time for ssh I still use putty because of the customization you can do with the appearance and lines of scrollback).
You can also use Cygwin to install ftp servers and web servers as well. You can even use it to install an ssh server on your windows laptop/desktop! *GASP!!!*
Why Install Cygwin-X?
And the big one: running x windows through ssh (in case vncserver is not viable for reasons of unencrypted transmission or port security). The main reason I do it is to install Oracle (which requires a gui). The second reason is to run IBM’s “uxspi” utility which can be done in text, but easier to read through the browser gui (it uses firefox).
I have used this most often with Oracle and IBM’s uxspi utility to load updates on IBM xSeries servers. Oracle requires an X-app to install, and the uxspi utility, while there is a text mode, is a bit easier to use as a GUI (it runs using a web browser). Definitely using Cygwin-x is a lifesaver. Bonus: since you’re running X-apps remotely and not an X desktop, you don’t even need vncserver running on the remote server.
That being said, let’s get to it!
Note: installation takes quite a long time, so be patient. If you plan to do this with other users laptops also, you can download and save all the packages and then copy that folder to the other computer to save you a lot of download time
Install Instructions For Cygwin-X
- Download the setup.exe
(I usually rename mine to cygwin_setup.exe since, well, setup.exe is such a generic name).
- Run the setup.exe. You will see the below window. Click “Next”
- Choose “Install From Internet”
- Choose a root directory for install (I use c:\cygwin)
- Choose directory for download of local packages this lets you install on another like machine without redownloading
- Enter your http proxy info if applicable if you are behind a proxy server at your location
- Choose a download site.
Now here is where you can find available download sites. Cygwin will look through every single site you select, so you want to only choose one, maybe two. The catch is, I have run into an issue once where one download site did not contain all the software I wanted. So what I would suggest, choose only one first. If for some reason it doesn’t have everything, then choose a second one in addition.
The thing with Cygwin is that it is SO LARGE (so many packages) that just searching one site takes a long time. Definitely do not choose more than three.
After you choose one (or however many), then click Next
- Click OK if there is an alert.
If you are installing Cygwin for the first time, you might get a “setup alert” which you can safely ignore. In fact, when I am upgrading Cygwin, I pretty much ignore this alert.
- Choose packages to install. Now comes the page where you can select the software to install. I’ll get to the X-server portion later. For now,
GO CRAZY YOU YOUNG KID IN A CANDY STORE!!!
If you are already an experienced linux/unix admin, you will know what you want. If you aren’t, then I would say just go through all the choices and choose something that looks familiar or you are curious about.
When you find something you want to install, click on the “Skip” button and a version number will now show up
That number is the version to be installed.
By default you will see some items already chosen by seeing a version number instead of the word “Skip”. There will also be a dependency check once you are done.
Also some software packages are in more than one group so if you click to install/uninstall in one group, it will replicate that change wherever else that software package is listed.
Some things you may not find because it is “hidden” inside of an entire package, so for me I usually choose anything that would say “utils” on it. Like for example below I chose “sharutils”. I don’t normally use uuencode and uudecode but it has come in handy and I’m guessing there are other neat utilities in sharutils I can use (you can always go back to the http://cygwin.com/packages/ and search also but it doesn’t tell you much)
Here is what I personally installed in addition to defaults:
Archive -> sharutils
Archive -> unzip (surprisingly not included by default)
Archive -> zip (ditto!)
Devel -> binutils (the strings command rocks)
Editors -> gvim/vim
Net -> curl (handy for scripting downloading of http URLs)
Net -> inetutils
Net -> openssh
Net -> ping
Net -> rsync (for copying files)
Net -> whois
Perl -> perl (just the main package - by the way this is a big package)
Shells -> xterm
Utils -> cpio
Utils -> util-linux
Web -> curl
Web -> lynx (old school!)
Web -> wget
- Now, for X-server, you need to install these packages (if you haven’t already)
xorg-docs (optional if you want the man pages)
X-start-menu-icons (optional for prettiness)
openssh (for running X over ssh, the point of why I do it)
Instead of looking for them you can use the “search” box at the top. Again don’t get thrown off if it shows up in multiple places.
When done. Click “Next”
- Click “Next” on the dependency check
- And now let the magic begin!
This will take some time so walk away and get some beloved coffee or caffeinated brew. Maybe 10 minutes?
- When done, choose whether to add to start menu or desktop and click “Finish”
Now when you click on the “Cygwin terminal”, you have your shell to type linux commands in. Go crazier!
One thing about navigation: You can reach your letter drives using /cygdrive/[drive letter]
So to get to your C: drive
# cd /cygdrive/c/
To get to your USB mounted drive on perhaps E:
# cd /cygdrive/e/
To get to your network mounted hard drive on H:
# cd /cygdrive/h/
and so on
Using Cygwin-X For Remote X Applications
Here is the x-windows portion you can run over ssh. Handy for Oracle installs, having to run firefox or any other gui “locally” on the machine but displayed on your windows
- Click on your Cygwin terminal icon to start Cygwin
- Type “startxwin”.
A lot of stuff will scroll by
And then finally a new window will open. This is where you can run your X apps.
- ssh to the remote box
ssh to the linux box you want to run an X-app on like so
ssh -g -X [user]@[ip]
ssh -g -X email@example.com
Now type in your favorite x-app. I like “xeyes” But xterm is a practical test.
- type in “xterm”
When it opens up, you now have an xterm on the remote host open on your windows desktop/laptop. VOILA!!! Xapps on your windows over (secure port) ssh
- p.s. run xeyes anyway! Do it!!