Create Amazon Web Services EC2 instance

Amazon Web Services are internet accessible computer services with usage-based fees instead of monthly fees. The most popular services are EC2 (Elastic Cloud Computing) and S3 (Simple Storage Service).

Amazon offers a free 1-year trial for new customers at aws.amazon.com/free. It's free as long as you are using a minimal amount of resources. The limits are clearly spelled out on the signup page. You may start paying for more features if you need them.

From their web page:

AWS Free Usage Tier (Per Month):

    • 750 hours of Amazon EC2 Linux Micro Instance usage (613 MB of memory and 32-bit and 64-bit platform support) – enough hours to run continuously each month*

    • 750 hours of an Elastic Load Balancer plus 15 GB data processing*

    • 10 GB of Amazon Elastic Block Storage, plus 1 million I/Os, 1 GB of snapshot storage, 10,000 snapshot Get Requests and 1,000 snapshot Put Requests*

    • 5 GB of Amazon S3 storage, 20,000 Get Requests, and 2,000 Put Requests*

    • 30 GB per of internet data transfer (15 GB of data transfer “in” and 15 GB of data transfer “out” across all services except Amazon CloudFront)*

    • 25 Amazon SimpleDB Machine Hours and 1 GB of Storage**

    • 100,000 Requests of Amazon Simple Queue Service**

    • 100,000 Requests, 100,000 HTTP notifications and 1,000 email notifications for Amazon Simple Notification Service**

    • 10 Amazon Cloudwatch alarms**

In addition to these services, the AWS Management Console is available at no charge to help you build and manage your application on AWS.

* These free tiers are only available to new AWS customers and are available for 12 months following your AWSsign-up date. When your free usage expires or if your application use exceeds the free usage tiers, you simply pay standard, pay-as-you-go service rates (see each service page for full pricing details). Restrictions apply; see offer terms for more details.

** These free tiers do not expire after 12 months and are available to both existing and new AWS customers indefinitely.

I'm using it as a free Linux virtual private server. This is enough to compile code, host a webpage, and run simple programs. It has about 9GB of free space, and ~100MB out of 613MB RAM free. Programs are actually only using less than 100MB, but Linux will use available free space to improve performance. Run free to see "actual" memory usage.

Prerequisites:

  • Email address

    • Home address

    • Phone number (cell phone OK)

    • Major credit card (debit works, Visa gift card worked after 3 days)

Optional:

Create free AWS account

  • Go to aws.amazon.com/free

  • Click "Sign up Now"

  • Enter use information, email address, etc.

  • Select EC2 tab

  • Register EC2 account

  • Provide credit card info, address, phone number

  • Verify phone number (Amazon will call you, enter 4-digit PIN)

  • Wait 1 minute for email confirmations:

    • Simple Storage Service

    • Elastic Compute Cloud (EC2)

    • Simple Notification Service

    • Virtual Private Cloud

Launch an EC2 instance

Be sure to select these minimum options, or you may be charged for exceeding "Free".

  • "Sign into the AWS Management Console" for EC2:

  • https://console.aws.amazon.com/ec2/home

  • Click "Launch Instance" button.

  • Click "Select" for "Basic 64-bit Amazon Linux AMI 1.0".

  • Select "Instance Type" Micro and click "Continue".

  • Click "Continue" without changing Advanced Instance Options.

  • Enter a Value for the "Name" key to identify your instance, and click "Continue".

  • Select "Create a new key pair". This is a different key pair from your own SSH keys. You should not import your own private key to the server, unless you want Amazon to know it ;)

    • Enter a name for this key pair, and click "Create & Download your Key Pair".

  • Move the downloaded private key to a secure directory.

    • I created $HOME/.ec2/ from MSYS

  • Enter a name and description for your "security group", and click "Continue".

  • Review the instance settings and click "Launch".

  • Click "Close".

  • In the "AWS Management Console" webpage, click on the "Instances" link.

  • Check the box for the instance you are running

  • Copy the "Public DNS" entry for later use.

Create an Elastic IP address for EC2 Instance

    • Go to "Elastic IPs" in the AWS Management Console navigation menu.

    • Click "Allocate New Address".

    • Click "Yes, Allocate".

    • Check the box next to the new Elastic IP address.

    • Click "Associate".

    • Select your EC2 Instance ID, and click "Associate".

You may use the IP address or "Public DNS" entry to connect to the instance with SSH.

Be sure to release the IP address after shutting down or terminating your instance; there is an hourly charge for IP addresses that are allocated but unused.

Connect to EC2 Instance with puTTY SSH

Download the latest puttygen from the main site: PuTTYgen Development snapshot

  • Run puttygen.exe

  • Go to "Conversions" > "Import Key".

  • Select the .pem key created for the EC2 instance.

  • Go to "File" > "Save Private Key". Click "Yes" to skip the passphrase.

  • Choose a protected directory, enter a .ppk filename and click "Save".

  • Run putty.exe

  • Go to "Connection" > "SSH" > "Auth".

  • Uncheck "Attempt authentication using Pageant" and "Attempt keyboard-interactive authentication".

  • Click "Browse" and select the .ppk file you generated.

  • Go to "Session" again.

  • Paste the "Elastic IP" address or "Public DNS" for your instance to the "Host Name" field.

  • Choose a name for the "Saved Session" field, and click "Save".

  • Click "Open", then click "Yes" to accept the signature.

  • Login as ec2-user.

  • Run sudo passwd root and enter a root password.

Creating limited user with same SSH key

The ec2-user may execute all tasks for root user by using sudo command. You may create a limited user without "sudo" powers, accessible by SSH and SFTP.

  • sudo passwd ec2-user

    • Change ec2-user password

    • If you choose a weak password, the system will complain but allow it

  • sudo useradd -c "Comment" username

    • Creates new user

  • sudo passwd username

    • Set password for new user

  • sudo mkdir ~username/.ssh

  • sudo cp .ssh/authorized_keys ~username/.ssh/

  • sudo chown -R username ~username/.ssh

  • sudo chgrp -R username ~username/.ssh

    • Copies EC2 SSH public key to new user and sets permissions

  • su - username to login as the new user

Configure FileZilla for SFTP to EC2 Instance

Start Filezilla.

Go to "File" menu > "Site Manager".

Click "New Site" and enter a description for your EC2 Instance.

Copy/Paste the Elastic IP or "Public DNS" for your EC2 Instance to the "Host" field.

Change "Server Type" to "SFTP - SSH File Transfer Protocol"

Change "Logon Type" to "Normal" or "Ask for Password".

Enter username and password.

Enter a comment in the "Comment" field.

Click "OK".

Go to "Edit" menu > "Settings".

Select "Connection" > "SFTP".

Click "Add keyfile..." and select the .ppk file you generated, then click "Open".

Click "OK".

Use the "Site Manager" menu (under "File") to select your EC2 Instance.

If all went well, you'll see a file listing in the "Remote site" section.

Terminate EC2 instance

If you're done using an EC2 instance forever, terminate it via the AWS Console. A simple shutdown may still leave the virtual instance running (?)

  • In the "AWS Management Console" webpage, click on the "Instances" link.

  • Check the box for the instance you are running.

  • Select "Instance Actions" > "Terminate".

  • The virtual server will run the "shutdown" sequence.

  • Go to "Elastic IPs" in the AWS Management Console navigation menu.

  • Select your Elastic IP and click "Release"

Install Amazon EC2 API Tools

  • Go to the EC2 developer tools page: http://aws.amazon.com/developertools/351.

  • Extract the ec2-api-tools.zip download to your development tools directory.

  • Rename the extracted directory to ec2-api-tools.

  • Determine the installed location of your Java Runtime Environment or SDK.

    • Go to "Control Panel" > "Java" > "Java" tab

    • Click "View..."

    • The location(s) are listed in the "Path" column.

  • Update your shell startup script:

    • Set and export EC2_HOME variable to the ec2-api-tools directory.

    • Add $EC2_HOME/bin directory to the PATH environment variable.

    • Set and export JAVA_HOME variable to the JRE installed location.

      • export JAVA_HOME="/c/Program Files/Java/jre6/"

  • Verify the installation by running ec2ver

Use public SSH key for AWS account management

  • Convert RSA SSH keys in MSYS to PEM format

    • Start MSYS

    • cd .ssh/

    • openssl rsa -in id_rsa -out id_rsa_pem

    • openssl rsa -in id_rsa_pem -pubout -out id_rsa_pem.pub

  • Upload access keys:

    • http://aws-portal.amazon.com/gp/aws/developer/account/index.html?action=access-key

    • Sign in again

    • Select "Key Pairs" tab

    • Click "Upload your own key pair" link

    • Click "Choose file" button, and select the public key id_rsa_pem.pub you created.

    • Click "Upload Public Key" button.

    • If you see this message: We were unable to install the Public Key you uploaded.

      • Your key must be in PEM format. My key was rejected until I used openssl to convert private key to PEM, then extract a PEM public key from that.

      • Your key should be 1024 bit. Generate a new pair with ssh-keygen or puTTY.

      • Make sure the key you upload has .pub extension

What Now?

Configure users, install packages. Don't transfer too much, or it's not free anymore!

Using a new EC2 Instance

More info:

http://s3.amazonaws.com/awsdocs/CF/latest/cf_dg.pdf