Here is the simplest way to have a virtual machine server running on amazon vm environment.
- Signup for an account at amazon webservices
- Generate a certicate and dowload whith private key
- Intall ec2 command line client on your machine
- Push your ssh keypair to amazon
- Run a vm and login via ssh !
1 Signup for an account at amazon webservices
Go the the aws home page and sign up for an account. This account will unique for all aws products (ec2, s3 etc..).
You have to fill your credit card. You will then have to be aware off all ressources you are using on aws at any time: this is the cost per use model.
There is an amazon console listing all of them with the related metrics (you can be charged by bandwith, disk io/rates and so on…).
2 Generate a certicate and dowload whith private key
Go on the amazon online console.
Create a X509 certificate on amazon aws console and download AT THE SAME TIME certificate and private key.
/tmp/pk-WSXXXXXXXXXXXXXXXXXXXXXXXX.pem
/tmp/cert-WSXXXXXXXXXXXXXXXXXXXXXXX.pem
3 Intall ec2 command line client
Ssh in your client server /machine (or maybe in local). Download and configure the client (it is java based, see sudo apt-get install openjdk-6-jre which could nout be suitable for your environment.
bob@server~: wget http://xxxxxx/ec2-api-tools.zip # get the url from the official site
bob@server~: unzip ec2-api-tools.zip
bob@server~: mv ec2-api-tools/* .ec2 && rmdir ec2-api-tools
bob@server~: cd .ec2/
bob@server~: mv /tmp/pk-WSXXXXXXXXXXXXXXXXXXXXXXXX.pem .
bob@server~: mv /tmp/cert-WSXXXXXXXXXXXXXXXXXXXXXXX.pem .
bob@server~: sudo apt-get install openjdk-6-jre
bob@server~: vi ~/.bashrc
Set this environment variables on your ~/.bashrc:
export PATH=$PATH:$EC2_HOME/binexport
export EC2_PRIVATE_KEY=$EC2_HOME/pk-WSXXXXXXXXXXXXXXXX.pem
export EC2_CERT=$EC2_HOME/cert-WSXXXXXXXXXXXXXXX.pem
export JAVA_HOME=/usr/lib/jvm/java-6-openjdk/
# if your want to work in european datacenter, set it by default# you can ignore this conf
export EC2_URL=https://ec2.eu-west-1.amazonaws.com
Test the client: it should be ok now
1.4.4.2 2011-07-15
bob@server~: ec2-describe-images -o self -o amazon
IMAGE ami-2e53785a ec2-public-windows-image............
it’s ok !
4 Push your ssh keypair to amazon
Register your ssh keypair on amazon so you can ssh your vm event just after the first boot.
5 Run a vm and login via ssh !
And now run a new instance with the correct type (t1.micro here, cheaper ), embedding your ssh keypair to log in (-k workstation-melie).
And the last but not list, the vm image (ami-359ea941) is provided by alestic, a ubuntu server repository. There a lot of amis (sql-server, centos, etc….) everything you can imagine and finding the suitable one could be tricky the first time. That’s why alestic could ba handy (for ubuntu fans off course…)
Check if you can see your instance:
its should be ok…
Log in the VM !
# you should be in your vm !
ubuntu@ip-10-227-177-18:~$ sudo su
root@ip-10-227-177-18:/home/ubuntu# halt
Kill your VM.
In the pay per use world, never waste resources ! Its time to drop our example instances.
Congrats !! you have run your first amazon ec2 server ! This is a really good starting point to experiment: test architectures with multiple servers, do performance bench on your services and so on…. and drop all servers where your done, maybe only several hours after…
Handy commands
Listing your available keypairs
Available regions id and api endpoint.
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


