SSH and X11 Forwarding Using Cygwin
This document describes how to use Cygwin to log into ARSC systems and remotely run X11 applications from Microsoft Windows. For complete instructions on using the X11 server, please visit the Cygwin/X main site and review their User's Guide. For information on Cygwin itself, see the Cygwin home page.
Installing The Necessary Software
To run remote X11 applications, you need to install an X11 server and an SSH client. Cygwin provides packages for both. For information on how to install Cygwin, please see the ARSC knowledge base article titled Installing and Using Cygwin. Ensure that you select and install the following Cygwin packages: openssh, xorg-server, and xinit.
Starting the X Server
Before you can use Cygwin/X to display X Window applications, it must be started. To do this, run the "startxwin" utility either in a Cygwin shell or from the XWin icon which should now be in your Start Menu. A white xterm window will open, and you will see the X Window icon appear on the right-hand side of your task bar.
Opening an X11-forwarded SSH connection
Next, you need to establish your secure shell connection with X11 support. To do this, add an -X and a -Y flag to your normal ssh connection. For example, a user with an ARSC account named jsmith would connect to an ARSC system named murgatroyd by typing the following into his opened xterm window:
It is easiest to establish proper X11 forwarding using the xterm window that opened when you started the X Server. This is because it sets a DISPLAY variable for you automatically, which is needed by the X Window System.
If you would like to establish the connection from your main Cygwin shell instead, you will have to set your DISPLAY manually. Either of these commands will do that.
Running Remote X Window Applications
With your local X server running, a DISPLAY set, and your SSH connection with X11 forwarding open, you should be ready to open remote X Window applications. To do so, open the program from your shell prompt as if you were on a terminal directly connected to the system (see Running a Program from the Shell Prompt for more information). Before you open any large applications (such as Matlab), test that you have set up your connection correctly by running "xlogo" in your shell. A window should open which looks similar to this:
If you see this image, a black X on a white background, then you have successfully set up SSH with X11 forwarding. You may now open other X11 applications in the same way.
My application returns the error "Error: Can't open display:"!
This error could be caused either by your DISPLAY variable not being set, or by the SSH connection not being flagged properly for X11 forwarding. Please log out of the ARSC machine you have connected to, and reset your DISPLAY environment variable.
Next, re-connect to the ARSC machine you were logged in to. Make sure that your ssh command has the -XY flags present.
My application returns the error "X connection to localhost:10.0 broken (explicit kill or server shutdown)."! (or similar)
This is an indication that your local X server is not running. Check the icons on the right-hand side of your task bar for the X Server icon. If it is not present, ensure that you installed xorg-server and xinit in Cygwin, and execute "startxwin" from your Cygwin shell. Once the icon is present, try opening your program again.