Running the course VM on AWS EC2

As an alternative to using qemu on a non-x86 computer, you can sign up for AWS EC2, which gives one year of free t2.micro usage. If you have a pre-existing AWS account and have already used up your free credits, consider creating a new account.

Step 1: Account Creation

Create AWS account. We will be using AWS free tier - so you may need to add a credit card but it will not be charged

Step 2: Security Group Setup Creation

  1. Navigate to EC2, then Security Groups, and create a new security group called "6566 SG"
  2. Add inbound rule: SSH, Anywhere IPv4
  3. Keep the default outbound rule: All traffic, ...

Step 3: Launch EC2 Instance

  1. You may follow the official AWS User Guide if these steps are unclear
  2. Use the AMI - Community AMI: ami-032c2461106e6aee3. Make sure that you're using the us-east-1 (N. Virginia) region.
  3. Instance type: t2.micro (free tier)
  4. Key pair: Create new, RSA, .pem, keep the resulting file 6566.pem, we’ll use it later
  5. Network settings: 6566 SG (existing security group, created in Step 2)
  6. Storage: 24 GB gp2 root volume (a free tier EBS Volume, do not add a new volume)
  7. Launch instance, allow it to start up.

Step 4: Connect to Instance

ssh -i 6566.pem student@<your EC2 instance Public IPv4 DNS here> (Using the key pair from Step 3.4. You may need to chmod 0400 6566.pem the first time you use it)

It will look like ssh -i "6566.pem" student@ec2-XX-XX-XX-XX.compute-1.amazonaws.com

Before moving on to Step 5, clone and build the lab according to the "Getting Started" instructions in Lab 1. Before attempting to connect to the web server, disconnect from SSH with exit and continue to the next part.

Step 5: Connect to Webserver

  1. Navigate to EC2, then Instance details, and note its public IPv4 address - we will use this IP address to setup SSH Port Forwarding
  2. This is different from the previous step! It will look like XX.XX.XX.XX
  3. (For Lab 1) Connect to the EC2 instance with port forwarding enabled by running ssh -i "6566.pem" -L 8080:localhost:8080 student@<your EC2 instance public IPV4 address here>
  4. Now, for example, in Firefox, you can direct the browser to localhost:8080 while the SSH connection is active
  5. (For Lab 2) The port forwarding command is instead ssh -i "6566.pem" -L 8888:10.1.0.4:8080 student@<your EC2 instance public IPV4 address here>, then you can access the site at http://localhost:8888/zoobar/index.cgi/ while the SSH connection is active

Step 6: Setup SSH profile

It might save time to encode the above SSH commands into profiles in the SSH config file (~/.ssh/config). Below is an example config, which uses separate profiles for whether you need port forwarding or not. Note that the semantics for the LocalForward option are LocalForward <host-ip> <remote-ip>:<remote-port>.

Host 566
    User student
    HostName <your-ec2-address>
    IdentityFile 6566.pem
Host 566fwd
    User student
    HostName <your-ec2-address>
    IdentityFile 6566.pem
    LocalForward 8888 10.1.0.4:8080

Step 7: End of Semester

  1. Fully terminate EC2 instance
  2. Fully delete EBS storage
  3. Remove credit card/delete AWS account
  4. Now, everything is cleaned up!