A virtual machine (VM) is essentially a file together with a client program that interprets that file. The file’s contents include:
From the user’s point of view, logging on to a VM looks very much the same as logging on to a remote server - with some important differences:
We will be using VMs provided by Duke’s Office of Information Technology (OIT). Each student must first claim a VM. Go to the VM Manage website:
https://vm-manage.oit.duke.edu/
Click the ‘New’ option at the top of the page. You will be prompted to enter some identification information and your Duke NetID and password. Next, you will be asked to name and describe your project. Use whatever is meaningful to you. Finally, when you are asked to choose a server, choose:
NGS Summer Workshop
Accept the terms of use and click ‘Request VM’. Now you should see some information pertinent to your VM. Most importantly, you need to record your URL and password. The URL will be of the form:
colab-sbx-XXX.oit.duke.edu
The XXX part is unique. You will see an initial password that you can cut and paste to login. If you know how to change a Unix password and wish to change it - go ahead, but it is fine to leave the default one. Just don’t enter any banking information or credit card numbers. :)
We will mostly be accessing the VMs using the Ipython Notebook. This lecture is written using said tool, and it is really, really useful! In this interactive environment, you can access the linux command line, write ‘markdown’ type text, use latex, run code, create files (scripts - more about that later) and run graphics. We will probably not get to use the full capability in this workshop, but you can learn more here:
http://ipython.org/notebook.html
We are going to setup the VM as a ‘notebook server’. This is essentially a web server that allows connections to the notebook via your browser.
Before we can actually use the notebook properly we need to configure a password for it. That means we will dive right in to ssh.
You can access your VM using the command line (a non-graphical, text-based interface). Many non Computer Science types find the command line scary and confusing. Don’t worry - you can’t break anything (at least nothing that cannot be fixed). The first thing you need to do is get a terminal client. If you are using a Mac - Good News! There is one built right in. Find the little screen (terminal) icon and click on it.
For Windows users: if you do not already have an ssh client, you will need to download and install one. Do this now:
http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html
Ok. Now that everyone has a way to ssh, do so using
ssh bitnami@colab-sbx-XXX.oit.duke.edu
(or the equivalent in putty)
Now, you should have a nice command line (shell) prompt:
bitnami@ubuntu14-generic-template-01:~$
(For short, I will just use the ‘$’ when representing the prompt)
Creating a Notebook Password
We are going to access our VMs via an
First thing we are going to do is to create a hashed password. This is a password that is encrypted using a ‘one-way’ algorithm. The hashed password has fixed length and cannot be reverted to the actual password. There are lots of programs that do this, but as we have it installed, we’ll use ipython.
$ ipython
In [1]: from IPython.lib import passwd
In [2]: passwd()
Enter password:
Verify password:
Out[2]: ‘sha1:67c9e60bb8b6:9ffede0825894254b2e042ea597d771089e11aed’
In[3]: quit
The text following Out[2]: is your hashed password. Copy this into the buffer by selecting and either using Cmd-C (Mac) or the putty menu. Include the single quotes.
Now, we are going to use a strange editor called ‘nano’.
Type:
$
And then change the line:
c.NotebookApp.password = u’sha1:51314c1d824e:c401b21da2e4bf6eb2c68a30d688b16858461f4b’
to use the password you created.
Type Ctrl-X to exit and <
enter>
to save.
Starting the Server
There is a shell script (just a file with commands) in your VM’s home directory (user=bitnami) called ‘startnb’. Run this in the background:
$ ./startnb &
Now, your notebook server should be up and running. To access it, open a browser window and point it to the URL:
https://colab-sbx-XXX.oit.duke.edu:9999
(XXX is your VM’s number).
You will need to enter your password. This is the password you created and placed in your notebook server configuration file.
Time to Play!
Once you have entered your password, you will see a directory listing. Let’s open the next lecture notebook!
Click on the directory ‘ngs-computing-bootcamp’ and the click on the file ‘BasicRinJupyterAndRstudio’