Preparing for the practical session

Connecting to the VMs

Windows Users

You need to use Putty to connect to the server. You should have already installed and tested this during the first day of the summer school.

Linux / Mac Users

You can use the preinstalled terminal that exist in your system

Activate the Anaconda Python Environment

The Anaconda Scientific Python Distribution is a really convenient tool, to install, manage, and use scientific python packages. It allows you to install a complete distribution, under a user directory, without conflicting with system packages. This also allows to have the latest version of Python, to older servers.

Anaconda is already installed in your systems, both in version 2 and 3.

For this workshop we'll use version 3.

Activating / Deactivating your Anaconda environment

Before we activate Anaconda, first let's check the current version of Python with python --version. The output should be similar to:

[cloud@sstestauto ~]$ python --version
Python 2.7.5

To activate your Anaconda environment, issue the following command on your VM.

source anaconda3/bin/activate

If you check again the python version you should get the following result:

(root) [cloud@sstestauto ~]$ python --version
Python 3.6.1 :: Anaconda 4.4.0 (64-bit)

NOTE: For this and the following workshops, it is assumed that you have activated the environment

Starting the Jupyter Notebook

You'll need to execute the following commands on your VM.

  • Generate Notebook configuration

    jupyter-notebook --generate-config
  • Set up notebook password

    jupyter-notebook password

    This is the password that you'll use to connect to the notebook.

  • Start the notebook in a "no-browser" session

    jupyter-notebook --no-browser --port=8889

Creating an ssh tunnel

To connect to the notebook that runs on a remote server, we could:

  1. Remove the security restrions imposed by Jupyter, and connect through http
    • Bad Practice
  2. Deplot an ssl certificated to the server
    • Best Practice, however too time consuming for ephemeral servers. (Interested people could take a look here)
  3. Start the server normally in the VM and forward the port through ssh
    • This is what we'll do

Windows Users

  1. Open a new Putty window

  2. Go to the SSH -> Tunnels

    • Source port: 8888
    • Destination: localhost:8889

  3. Then at the session tab, fill again the IP of your server as before

Linux / Mac Users

Open a new terminal window and execute the following command, replacing <IP> with the IP of your server

ssh -N -L localhost:8888:localhost:8889 cloud@141.5.102.194

The command will not return, and keep running. To stop it you can issue a CTRL+C.

Alternatively you could also:

  • Add the -f flag, for the command to go to background. You can utilize the terminal, but it is easy to forget that you started it later.
  • Remove the -N flag. This will allow you to use a terminal in the remote machine

Connecting to the Notebook

Now you should be able to go to http://localhost:8888 and connect to your notebook. You would be asked to provide the password that you created at the beginning.

You should be seeing something similar to this:


In [ ]: