Accessing VM

The course VM can be either a local VirtualBox VM running on the hardware of your host, or a remote VM running on the Amazon AWS. In either case, the VM runs Ubuntu 14.04 (with Lubuntu Desktop), a popular distribution of the open-source Linux operating system.


Shell Access

Shell Access from Mac Host

From your host shell, inside the directory containing your Vagrantfile, run vagrant ssh. You will then have a command-line VM shell. This assumes that your VM is already up and running (see Creating and Running VM for details).

You can run multiple host shells and start a vagrant ssh session in each one of them to get multiple VM shells, which you can use for multitasking.

Shell Access to Local VirtualBox VM from Windows Host and MobaXterm

In MobaXterm, click on the Session button to start a new “session.” Choose SSH. Under “Basic SSH Settings,” enter 127.0.0.1 for “Remote host”; specify the user name to be vagrant; change port to 2222. Then, click on “Bookmark settings” tab, and give this session a memorable name, such as 216-VBox. Finally, click OK to continue. If all goes well, a new SSH tab will open up, and you will prompted for password (which is vagrant).

To reconnect, go to your saved sessions in MobaXterm (accessible from the vertical tab with a star), and simply double-click on the saved session name.

You can run multiple instances of the session, which you can use for multitasking.

Shell Access to Remote Amazon VM from Windows Host and MobaXterm

From your host shell, inside the directory containing your Vagrantfile, run vagrant awsinfo. Assuming that your Amazon VM is already up and running, you will see a bunch of information. Take a note of the value of the public_ip: that is the public IP address of your Amazon VM.

In MobaXterm, click on the Session button to start a new “session.” Choose SSH. Under “Basic SSH Settings,” enter the public IP address of your Amazon VM for “Remote host”; specify the user name to be ubuntu. Then, click on “Advanced SSH settings” tab blow, enable “Use private key,” click on the icon on the right end of the input box for “Use private key,” and browse to your datacourse.pem file. Then, click on “Bookmark settings” tab, and give this session a memorable name, such as 216-AWS. Finally, click OK to continue. If all goes well, a new SSH tab will open up, and you will have a shell on your Amazon VM.

Whenever you shutdown and reboot your Amazon VM (using vagrant halt and vagrant up in your host shell), your VM’s public IP address may change. Therefore, after every reboot, you should run vagrant awsinfo to get the up-to-date public IP. Then, to reconnect, go to your saved sessions in MobaXterm (accessible from the vertical tab with a star), right-click on your session name and select “Edit session.” Change the the IP address to the new one, and click OK. You can then double-click on the saved session name to connect.

You can run multiple instances of the session, which you can use for multitasking.


GUI Access

GUI Access to Local VirtualBox VM

If your VM runs locally on your own computer, and if you have followed the setup instructions correctly, you will see a window showing the VM desktop with the login screen once you start your VM. (For convenience, you might want to make this desktop full-screen; read VirtualBox documentation for details.) Just log in as user vagrant with password vagrant.

Here is a list of useful GUI-based programs already installed on your VM. You can find them by clicking on the icon located at the lower-left corner of the VM desktop.

  • LXTerminal (under Accessories) gives you another VM shell. You might find it convenient to run multiple shells for multitasking.
  • File Manager (under Accessories) gives you a GUI for exploring folders and files on your VM.
  • Document Viewer (under Graphics) is for viewing PDF and images.
  • Chrome (under Internet) is the default Web browser. You can use it to WebSubmit files on your VM.

GUI Access to Amazon VM

Follow the instructions below to prepare your host and log into your Amazon VM. Once you are in an appropriately configured VM shell, you can then type the following commands to launch GUI programs on your VM and have them display on your host:

  • xterm & gives you another VM shell.
  • pcmanfm & gives you a GUI for exploring folders and files on your VM.
  • evince & is for viewing PDF and images.
  • google-chrome & launches the Web browser. You can use it to WebSubmit files on your VM.

Note that by ending the command with “&“, we launch the GUI app “in background” separately from the VM shell, so you can continue using the shell for something else.

From Windows Host with MobaXterm

Simply follow the instructions above on getting shell access to remote Amazon VM from Windows host and MobaXterm.

From Mac Host

First, you need to install XQuartz on your Mac.

To be able to run GUI programs from your VM and display them on your Mac host, you need to follow a slightly different login procedure:

  • On you Mac host, start XQuartz (X11 server).
  • Under the X11 menu, start an “xterm” (under Applications). (This is a host shell same as what you get with Terminal, but with correct setup for X11, which you will need for the subsequent steps to work.)
  • In the xterm, go into the directory containing your Vagrantfile and log into your VM:
    vagrant ssh
    (Of course, you will first need to start up your VM if you haven’t already.)

File Access

Accessing Files on Local VirtualBox VM

If your VM runs locally on your own computer, and if you have followed the setup instructions correctly, you will find a directory named shared under your home directory on the VM. This directory automatically mirrors the directory containing the Vagrantfile on your host. For example, to work on hw01, you can make a subdirectory hw01 under the directory with Vagrantfile on your host. Then, you may create and edit a file named intro.txt inside this subdirectory (using a text editor on your host). Your VM will see this file automatically as shared/hw01/intro.txt. Inside your VM, change your working directory to shared/hw01:
cd ~/shared/hw01/
and continue your work there, e.g.:
ls -l intro.txt
nano intro.txt

Conversely, if you update anything under shared/ on your VM, you will find the changes reflected automatically on your host. Thus, you can use WebSubmit to submit such shared files from a browser on either your VM or host.

Accessing Files on Amazon VM

There is no automatically mirroring of files between your VM and host. You can always work exclusively on your Amazon VM, using VM shells for text-based tasks, and GUI access for tasks involving GUI.

However, if you really want to access the files on your VM from your host, you can use a secure FTP program (read further below for recommendations) to transfer files from and to your VM. For example, if you want to WebSubmit some files on the VM for grading, but don’t want to set up GUI access to your VM, then you can first download the files to your host, and then use a browser on your host to submit them via WebSubmit. For another example, if you don’t like using programs like nano inside your VM, then with secure FTP, you can create/edit code or input files on your host (using whatever your favorite editor is), upload them to your VM, work inside your VM through vagrant ssh, and then download any output files from your VM back to your host. You will need to remember to synchronize the files constantly and appropriately.

If you have a Mac host, we recommend FileZilla (free from Duke OIT). To set up FileZilla, follow the instructions here, which also points to a video tutorial. Tip: FileZilla has a built-in file editing future. You will need to enable it explicitly under settings; make sure you choose to “watch locally edited files and prompt to upload modification.” Once enabled, this feature allows you to select a remote file in the FileZilla interface and view/edit it in-place.

If you have a Windows host and use MobaXterm, good news—it has a built-in secure FTP tool. As long as you have an active shell on your remote VM, you will find an “Sftp” vertical bar to the left of your shell, which gives you access to the remote files. You can right-click on a file to see the list of available actions; “Open with default text editor” will allow you to edit this file “in place.”