Remotely Accessing the CS Zoo
Table of contents
You are welcome to use your personal computer; however, there is always a possibility for compatibility issues depending on your OS and the version of Python you have installed. The instructors and TAs will not assist with debugging software compatibility issues on personal computers.
We will be running your code on the CS Zoo computers; if you test your code on the Zoo, you can be confident that it will produce the same results when we grade it.
The Zoo can be used in three different ways:
- Visit the 3rd floor of AKW and log in directly on one of the Zoo consoles.
- Pros: No need to install any software on your own computer.
- Cons: You have to physically be in AKW.
- Log in from another computer via
ssh
and use the command line tools.- Pros: You can access the Zoo from your own computer, wherever it’s located.
- Cons: You’ll need to get quite comfortable with using terminal commands (though this may be a long-term benefit!). While it is possible to view visual output from your code (see below for more details), you will not have access to the computer’s full GUI.
- Create a Virtual Network Computing (VNC) remote Zoo desktop on another computer. This provides a full graphical interface to the Zoo environment.
- Pros: You can use your own computer to view the Zoo computer’s screen as if you were sitting in front of it in AKW.
- Cons: Using a VNC requires a lot of bandwidth and the connection can be “laggy”.
Option 1: Visit AKW
All enrolled students in this class should have card access to AKW. If your card does not give you access, let us know right away!
Option 2: Connecting Using SSH
SSH is used both to make the initial contact with the Zoo and to establish an encrypted tunnel between your machine and the Zoo for use by VNC.
Most Linux distributions and Mac OS X already have ssh installed. For Windows machines, you will need to install an SSH client such as Putty that supports tunneling.
SSH from Linux and Mac OSX
Linux machines and Macs with OSX should have a version of OpenSSH already installed. Open a terminal window, run the following command, and follow the prompts to log in:
ssh <username>@node.zoo.cs.yale.edu
By default, your username and password are the same ones you use for logging in with your Yale NetID. The server name node.zoo.cs.yale.edu
selects one of the Zoo nodes automatically for you. Important: Make a note of which node you are actually connected to in case you need to go back to it later.
You can connect to a specific Zoo node like this:
ssh <username>@tiger.zoo.cs.yale.edu
Enabling X11 Forwarding
These ssh commands will enable a text-only connection. If you are not using VNC and want to run code that produces a visual output, you will need to enable X11 forwarding.
On your computer, use the terminal to open the file ~/.ssh/config
using your preferred text editor and add this line:
ForwardX11 yes
On Mac, you will also need to install XQuartz. You can download this package online or use homebrew (which is an excellent tool for installing packages) like this:
brew tap homebrew/cask
brew install --cask xquartz
You may need to restart your computer after installing XQuartz.
To test, log into the zoo using the -Y
flag:
ssh -Y <username>@node.zoo.cs.yale.edu
And then verify that a window pops up on your screen after you enter the command:
xterm
SSH from Windows
The instructions below describe how to use Putty on Windows to both open an SSH session to a Zoo node and also to forward the VNC over the same connection. The first VNC server to be started on a node uses port 5901
, the second 5902
, and so forth, so these are the ports that need to be forwarded from the Zoo node back to your machine.
- Connect to a free node in the zoo by using
node.zoo.cs.yale.edu
as the host. You can also substitute a specific node name. - To avoid having to perform all of these steps every time you bring up putty, enter this same value in the saved sessions textbox and click “save.”
- Select the new item from the saved session list and click “load.” You will now be editing the details for your saved session information.
- Before connecting, go to Connection > SSH > Tunnels on the left menu.
- You will need to add the ports that you will be using. Usually the ports will be
5901
or5902
, but if there is a lot of activity you may have higher ports. For each port you add, in the destination text field, addlocalhost:PORT-NUMBER
. So, to add port5901
, you should putlocalhost:5901
in the destination field. - Once you have added some ports, go back to the Session option on the left panel.
- Make sure “only on clean exit” is selected at the bottom before connecting.
- Click “save.” This step is important since it will save the session information you just edited so that you don’t have to add all the ports again the next time you want to connect. For future connections, you can just select the correct option in the saved sessions list and click “load” before connecting.
- To connect, click “open.” Once a command prompt pops up, log yourself in.
Enabling X11 Forwarding
These steps will enable a text-only connection. If you are not using VNC and want to run code that produces a visual output, you will need to enable X11 forwarding:
- Install an X server on your computer, such as vcxsrv or cygwin.
- When following the previous steps for setting up a Putty connection, go to Connection > SSH > X11 and check “Enable X11 forwarding”.
Option 3: Connecting Using a VNC
Establishing and using a VNC connection involves three steps:
- Start a VNC server on the Zoo node.
- Start a VNC viewer on your (local) machine.
- When you’re done using the Zoo, cleanly exit the VNC server.
Starting up the VNC Server
- Connect to the Zoo using SSH.
- Run the command
vncserver
. To set the window size, runvncserver -geometry 800x600
(or whatever your preferred resolution is) instead of justvncserver
. - If this is the first time you have used
vncserver
, you will be asked to set up your server at this point, and will need to supply a password for it. You will be asked for this password when running the VNC Viewer. - Once set up, you will get a message like this:
New ’X’ desktop started on grizzly:1
Make note of the node name and the number at the end, which is the X display number. Your server is listening on port 5900+n
, where n
is the display number.
Putty users: That port must have been added previously to the list of ports to be forwarded to the local node. If 5900+n
is higher than any port you added when configuring Putty, you’ll have to close Putty, restart it, add the new port(s), and then connect again. Before closing Putty, be sure to shut down the server cleanly as described at the end of this page.
Starting up the VNC Viewer
On Windows, you will need to install a VNC viewer such as TigerVNC. Open up TigerVNC Viewer and tell it to connect to localhost:n
. From the example above, this would be localhost:1
. You should get a window asking for the password you created earlier.
Do not make the mistake of connecting directly to grizzly:n
. This will also work, but it will open an ordinary (unencrypted) TCP connection to the node “grizzly”, and your connection password will go out in the clear. By connecting to localhost:n
, you are sending your connection through the SSH-encrypted tunnel previously created.
On Mac, you can use the built-in VNC viewer. But first, you need to create an SSH tunnel to the node you want to access. From another Terminal window, if your display number is 1 (as explained above) execute:
ssh -L 5901:localhost:5901 <username>@nodename.zoo.cs.yale.edu
Otherwise change the port to 5900+n
, where n
is the display number. Here, nodename
is the name of the node you connected to when setting up the VNC server.
Now in another Terminal window, run:
open vnc://localhost:5901
Replace 5901
with whatever 5900+n
port you used previously. You should get a window asking for the password you created earlier.
On Linux, run:
vncviewer -via nodename.zoo.cs.yale.edu localhost:n
Following the example above, this would be
vncviewer -via grizzly.zoo.cs.yale.edu localhost:1
After entering the password created when running vncserver, a remote desktop should show up.
Exiting Cleanly
When you are done using the Zoo node, you must exit cleanly and make sure you do not leave behind running Xvnc server processes. (The command vncserver
is used to create and terminate the server; the server itself is called Xvnc.) If you forget to kill the server, it will continue to run even after you log out. The next time you or anyone else runs vncserver
, a new Xvnc process is created and assigned the next larger display number.
The safest way to clean up is to issue the command
vncserver -kill :n
where :n is :1 or :2 etc. depending on the display number n that was shown to you when the server started. You can also use the command
killall Xvnc
to kill all of the Xvnc server process that you own.
Acknowledgment
This document is based on one by Prof. Michael Fischer.