AWS EC2 set up

I have done this several times before, but still want to record the steps to setup a EC2 instance. Now that Amazon offers free service for the first year (only with micro instance), I decided to go through the whole process and try other services too like cloud-front.

First, sign up with Amazon Web Service. Then sign up with EC2.
Log on to the Amazon Management Console, to launch a EC2 instance.
To do so, we need a key pair – select the “key pairs” to create a new key pair for EC2 use. Download and save the private key to local. Then it is time to launch a EC2 instance -I use the ubuntu AMI ami-508c7839. Choose micro instance (free). Choose default settings (ie, default security group). And launch it.
With the free instance we can go ahead to associate with a static IP. Click the “Elastic IP”, allocate one IP address, and associate with the new instance.
Now we have a Linux server fired up with a static IP address.

Next, we need to set up the SSH access to the new server. First, still on the AWS Management Console, select the Security Group, and choose the Default Security Group, add the “SSH” to allowed connections, for now, keep the default setting for example port 22 and source IP being “” – this means any IP can try to ssh this server. This is not really safe, but for now we keep it.

Ok, let’s try it. Start a terminal, enter the directory where the downloaded private key (a .pem file) exists, and enter command
ssh -i ./xxxx.pem ubuntu@
( is the elastic IP address we allocated earlier)

This will fail with message like below:
Permissions 0644 for ‘./xxxx.pem’ are too open.
It is recommended that your private key files are NOT accessible by others.
This private key will be ignored.

The reason is AWS doesnt want you to keep the private key file too open, so, let’s change it to 600 (only owner can read)
chmod 600 ./xxxx.pem
then try the SSH command again, this time, you will be able to log in.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s