Sunday, September 25, 2011

Getting Command Line Access to Amazon EC 2 / Web Service

After signing up for the AWS account, did the following steps to get started with command line access to my instance:
$ sudo apt-get install sun-java6-jdk
  • Added the following to .bashrc for the EC2 environment variables: 
export JAVA_HOME=/usr/lib/jvm/java-6-sun-1.6.0.26
export EC2_HOME=/home/thejus/aws/ec2-api-tools-1.4.4.2
export AWS_RDS_HOME=/home/thejus/aws/RDSCli-1.4.007

export PATH=$JAVA_HOME/bin:$EC2_HOME/bin:$AWS_RDS_HOME/bin:$PATH

export EC2_KEY_DIR=/home/thejus/aws/keys
export EC2_PRIVATE_KEY=${EC2_KEY_DIR}/pk-Y36R3VDKYF55PYKVXR3VFGSNCY7AQGLS.pem
export EC2_CERT=${EC2_KEY_DIR}/cert-Y36R3VDKYF55PYKVXR3VFGSNCY7AQGLS.pem
  • Run this command to verify that the command line tools are set up:
$ ec2-describe-regions 

REGION eu-west-1 ec2.eu-west-1.amazonaws.com
REGION us-east-1 ec2.us-east-1.amazonaws.com
REGION ap-northeast-1 ec2.ap-northeast-1.amazonaws.com
REGION us-west-1 ec2.us-west-1.amazonaws.com
REGION ap-southeast-1 ec2.ap-southeast-1.amazonaws.com

  • Launch the instance from the AWS management console: I selected the ubuntu server instance type instance: i-72fb9e12 (ubuntu-server), mainly to stay within the free tier limit, along with the micro type.
  • Download the key during the instance creation process and save in key directory.
  • Run this command to check the status of the instance once started:
$ ec2-describe-instances
  • Enable ssh connectivity to the instance using this command:
$ ec2-authorize default -p 22 -s 0.0.0.0/0
  • Once the instance is in a running state connect to the instance using ssh: 
$ ssh -i thejus.pem ubuntu@ec2-72-44-48-18.compute-1.amazonaws.com


If you see the ubuntu command prompt on the Amazon instance then you are successfully logged in!

No comments:

Post a Comment