Cloud boxing…Getting an Ubuntu Box with AWS

James W. Goedert
6 min readMay 24, 2017

--

Wanting a little more power than Heroku or Digital Ocean has to provide? Don’t have a billion dollars or a lot of time?

For quite some time I’ve heard about the headaches of using Amazon Web Services for Deployment. This led me to lean on the sleek and easy to use Digital Ocean’s “droplet” system for my last several deployments. Digital Ocean offers free, easy to use, and easy to understand platform for pushing your full-stack apps up to the web, just as simply as you might run them on local host.

The key, is that they give you an empty machine that runs its pretty little heart out all day long, so you don’t have to run around with your machine showing your friends what you made, or even worse clients, what they might be able to have if only they had your computer. Enter, the Ubuntu box.

For this installation I am going to cover setting up an Ubuntu shell using AWS’s EC2(or elastic compute cloud) system with an AMI(amazon machine instance). Don’t worry, a light appendix of all amazon’s clever and confusing acronyms will follow.

There are a few main steps to getting up and running, all of them simple if followed in order. Let’s begin.

You will first need to sign up with an AWS account and provide your information, including unfortunately your credit card info. AWS offers most of its basic services on a ‘free tier’ where you can explore and deploy projects at a certain scale before fees kick in, but it is important to keep track of what goes where, or you’ll end up with unwanted pennies flying our of your purse.

After your account is set up, you will be redirected to your dashboard, or from the welcome screen you can simply click the ‘Sign in to the Console’ on the upper right corner.

Type EC2 into the search bar if the icon is not already visible.

One of the wonderful features of AWS is also one of its pitfalls. Options. There are literally hundreds of different ways/configurations do accomplish what you’re after. It’s like going to Cosco rather than your local grocer when all you want is a dozen eggs. This quick look will help you find that dozen eggs and get out the door.

Your EC2 Dashboard

From your EC2 dashboard you have access to all the myriad of options on your left scroll bar, and a breakdown of current statuses of resources at the top. Here we can what all I have setup and running and navigate directly to them, or they can be reached via the left menu.

We will only be dealing with a handful of these.

Our instance panel is where we’ll start of(navigable from the left or by clicking ‘running instances’. Click the ‘Launch Instance’ button to… launch an instance.

Here you will chose you AMI or Amazon Machine Image from a long list. We’re going to go with Ubuntu 16.04.

Make sure whichever image you choose has ‘free tier eligible’ marked under its icon

Our next choice is to chose an instance type, in this case we’re going for broke, and going to stick with AWS’s free tier eligible option of t2.micro. As long as you use this configuration on your instances, Amazon will only charge for additional services or begin billing after 750 hours of use.

Choosing our instance type.

The next 5 steps can be viewed by clicking ‘Next’ but for the purposes of this tutorial, we are going to only go to Configure Security Group. From here we can configure our firewall to allow access to our specified ports on http and https.

We’ll add two rules, HTTP at port 80 from ‘anywhere’, and HTTPS on 443 from ‘anywhere’. This will allow everything to be served up without getting blocked by Amazon’s protection, we can stick with the default values for our Security group name and description, or change them as you see fit.

You will hit the above error screen, but as we are not deploying anything, things will be quite alright, and we can move on to launch.

The next step is to create a key value pair or chose an existing one. I will create a new pair to walk through the process of creation, storage, protection and launching of our AMI. Chose ‘Create a new key pair’ from the scroll down menu and name your keys. I named mine ‘practicePair’ and then clicked the ‘download key pair’ button to save them to my local machine.

These are your ssh keys that will be used to grant you access to your virtual box. At the root directory of your terminal you should have a ‘.ssh’ directory, otherwise you will need to create one.

If you already have a directory and are using a mac, go ahead and run the following to drop your newly downloaded keys into the .ssh directory.

Here we can see that ‘practicePair.pem’ keyset has been moved.

You can simply click on the instance ID to navigate back to dashboard after clicking the ‘Launch Instance’ button.

Successful Launch!

From the dashboard, we’re provided with some valuable information that will be needed to SSH into our machine. You’ll want to take a note or copy of the IPv4 Public IP located in the lower left corner for the next step.

We’ll first need to protect our keys by altering their permissions using chmod command in terminal.

For a better understanding of the chmod commands visit. https://ss64.com/bash/chmod.html

Now that we’re protected, with verified keys, it’s time to jump into our box.

Replace practicePair.pem with whatever you named your keys, and adding your IP address after the ‘@’ symbol.

You’ll be prompted with a message warning that your authenticity can’t be established and asked if you’d like to continue connecting. You would. Type yes and hit enter.

Here’s the keys, you’ve found your new home!

If you get any errors, check to verify you named your keys correctly, the IP matches that which you found in your ‘Instances Dashboard’, and verify(delete and retype) ubuntu before you @ your IP.

The very last thing you’ll want to do before installing node or any other goods is to update and upgrade your environment to make sure everything is up to date.

Watch the GETs fly by while your machine establishes its first breaths and say Y to your first prompt. Two pink screens later with additional Yes-I-do’s and you my friend are the proud new owner of a piece of cloud.

the much-awaited appendix of amazacronyms:

EC2-elastic compute cloud

AMI- amazon machine image

ECS- elastic container service

EBS- elastic block store

VPC- virtual private cloud

CIDR- classless inter-domain routing

NAT- network address translation

IAM- identity access management

SDK- software developer kit

WT- what the…

--

--