Getting Started with Amazon EC2 for Windows Users
Before I get started, I just want to point out that I’ve got no affiliation with Amazon and that this guide is to try and help you get started with EC2. This tutorial requires reasonable competency with Windows and potentially some experience with Linux, please read over the post before you get started and check out the docs on Amazon to make sure you understand their terms of service.
The following guide should hopefully get you up and running such that you can boot your Amazon Elastic Compute Cloud (EC2) images from within a Windows environment. In particular, we’ll be booting one of the public images running Fedora Core 4.
You’ll need the following before you can get started, you may skip any section for a pre-requisite that you might already have. Note that all the software required to get started is freely available.
Java Runtime Environment
To get started you’ll need a Java Runtime Environment (JRE) as it’s a dependency for the EC2 tools. Look inside C:\Program Files\Java to see if you’ve already got one, if that folder doesn’t exist then download the latest JRE from the SUN site. I don’t recall whether the JRE bin folder is put in your path as part of the installer, but if it isn’t right click on “My Computer”, then click “Properties” > “Advanced” > “Environment Variables”. Under “System Variables”:
- add JAVA_HOME as the location to your JRE.
ie. C:\Program Files\Java\jdk1.5.0_09 - append the bin folder to your Path.
ie. C:\Program Files\Java\jdk1.5.0_09\bin
You might want to open a command window at this point and type: java -version. If you don’t see output like the following, you’ve made an error above.
java version "1.5.0_09" Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_09-b01) Java HotSpot(TM) Client VM (build 1.5.0_09-b01, mixed mode, sharing)
PuTTY/PuTTYGen
Next you’ll need an SSH client and SSH keytool. The defacto standard is PuTTY and it’s sister tool PuTTYGen. You can download these tools from the PuTTY Download Page. There aren’t any installers, I recommend you place them in a location such as C:\Program Files\Utilities.
WinSCP (Optional)
In case you want to move files from your computer to your running instance, you’ll need an SCP client. SCP is similar to FTP except it is secure as it uses the SSH protocol. A great Windows frontend is called WinSCP. I recommend you just use the installer and perform a default install. You may freely download WinSCP 3.8.2 from the
sourceforge site.
EC2 Tools
Finally, you’ll need the Amazon developed EC2 tools. You may download them from the Amazon site. I recommend you extract the archive to a directory such as C:\Program Files\ec2.
Summary of Tools so far
At this point I’ll assume you’ve got an install that looks something like the following…
- JRE - C:\Program Files\Java\jdk1.5.0_09
- EC2 Tools - C:\Program Files\ec2
- PuTTY/PuTTYGen - C:\Program Files\Utilities
Any paths referenced in this post from here on in with paths similar to the above you may replace with wherever you might have installed the pre-reqs to.
Preparing your Environment
Download your private key/public key pair from the “Your Account” section of the AmazonAWS site. A logical place to put the keys might be something like C:\Documents and Settings\Your Username\My Documents\ec2. You should have 2 files cert-XXX.pem and pk-XXX.pem where XXX is the unique id that Amazon defined.
At this point to use the tools you need to add a number of things to your path and set a few environment variables. To make this easier I created a bat file inside C:\Program Files\ec2 called prepare_env.bat, the contents of this file are outlined below. Substitute any path names and files as necessary.
rem Setting up EC2 Home set EC2_HOME=C:\\Program Files\\ec2 set PATH=%PATH%;%EC2_HOME%\\bin rem Loading Keys set EC2_PRIVATE_KEY=c:\\Documents and Settings\\Your Username\\My Documents\\ec2\\pk-XXX.pem set EC2_CERT=c:\\Documents and Settings\\Your Username\\My Documents\\ec2\\cert-XXX.pem
Load up a command window (Start > Run > cmd.exe), and cd to your ec2 folder. Run the prepare_env.bat script. If everything worked correctly, then cd into the bin folder. At this point you should be able to run one of the EC2 tools, try ec2-describe-images -o amazon. The following is a sample screendump:
C:\\Program Files\ec2\\bin>ec2-describe-images -o amazon IMAGE ami-20b65349 ec2-public-images/fedora-core4-base.manifest.xml amazon available public IMAGE ami-22b6534b ec2-public-images/fedora-core4-mysql.manifest.xml amazon available public IMAGE ami-23b6534a ec2-public-images/fedora-core4-apache.manifest.xml amazon available public IMAGE ami-25b6534c ec2-public-images/fedora-core4-apache-mysql.manifest.xml amazon available public IMAGE ami-26b6534f ec2-public-images/developer-image.manifest.xml amazon available public IMAGE ami-2bb65342 ec2-public-images/getting-started.manifest.xml amazon available public
If you don’t see the above, or something very similar, then something is wrong. I’d recommend you go back through the tutorial and check your Java path as well as your prepare_env.bat. If it did work, then you’re ready to start loading up some remote images :).
Loading the Amazon Public Base Image
Amazon has a number of public images available, in fact the command you ran before listed 5 of them! The only problem with an image being public is that everyone knows the password to access your image. To avoid this problem, Amazon makes the actual password for the public images unavailable to the public, instead when you’re booting an image they allow you to attach the public portion of a key pair to your image such that you can login with a private key!
In order to create a key pair, run the following command: ec2-add-keypair my-key, you’ll receive output like the following:
KEYPAIR my-key 61:76:bb:3f:81:da:0f:5d:28:e4:36:70:f4:1b:26:f3:f9:3c:c0:10 -----BEGIN RSA PRIVATE KEY----- B64 HEX HERE.... -----END RSA PRIVATE KEY-----
Copy paste everything but the first line into a new notepad document and after the —–END RSA PRIVATE KEY—– line add a single newline. We’re now going to take this private key file and convert it into a private key that PuTTY can read, save this file in your My Documents\ec2 folder as AmazonPK.ppk.
We now need to convert this Private Key format to the format PuTTY understands. To do this, we’ll open up PuTTYGen.

Choose the option to “Load” a Private Key. Then click “Save private key”, I recommend you Save this new Private Key right over the top of the old one. It’s ok to save the private key without a passphrase.
At this point we can boot a public image from the command line. In this instance we’ll boot the Fedora Core Base Image. The following is sample output.
C:\\Program Files\\ec2\\bin>ec2-run-instances ami-20b65349 -k my-key RESERVATION r-401aff29 904177591104 default INSTANCE i-6312f60a ami-20b65349 pending my-key 0
Note that the image is in pending state. We may check the state of the image by running the following. Note the instance number of i-6312f60a is substituted into the next expression, your instance number will definitely be unique.
C:\Program Files\ec2-api-tools-1.2-7749\bin>ec2-describe-instances i-6312f60a RESERVATION r-401aff29 904177591104 default INSTANCE i-6312f60a ami-20b65349 domU-12-31-33-00-04-02.usma1.compute.amazonaws.com running my-key 0
You’ll want to keep running the command until you see your instance as “running”, it might take 5 minutes for your image to go live.
Connecting to your Image
Now that the image is live, you’ll want to connect to it. You’ll firstly need to open up the SSH port on the firewall, the following is sample output:
C:\\Program Files\\ec2\\bin>ec2-authorize default -p 22 GROUP default PERMISSION default ALLOWS tcp 22 22 FROM CIDR0.0.0.0/0
Now that the firewall on our image is open for SSH access, open up PuTTY. Enter the address to the image as returned earlier (but don’t connect yet).

You’ll now want to switch to Connection > SSH > Auth, and add your private key.

At this point you may click “Open”. You’ll be asked if you want to add the key to the cache, as you’ll most likely get issued a new IP next time, click No. When asked who you want to login as, enter the username “root”. Assuming everything worked, you’ll see the following:

Congratulations! You’re all done. When you’re done exploring the image do not forget to shut it down. There are 2 ways of doing this, within your Amazon tools there iis a tool called ec2-terminate-instances, which you can pass your instance id as a parameter. Alternatively, from within PuTTY run “shutdown -h now”. Note that when you terminate your instance, all changes will be lost.
In a following tutorial I’ll outline a basic mono setup, as well as how to persist your image.








[...] Before we get started, I’ll assume you’ve got the Amazon Fedora Core 4 image up and running. [...]
[...] how to get Amazon EC2 to work with Windows... Well, how to get the tools to work with Windows anyway. ArbFranklin has a post explaining all you need to know. I have had an EC2 account with amazon for a while now, but never got it working. this should be interesting though. i have to try it out. As a second point, Enomaly has an article showing you how to run Windows Server on an EC2 instance. they use QEMU to do emulation, and you may have to use a linux box to do the building of images, etc, but, if it works, and works properly, this is sweet!
Published Saturday, December 30, 2006 5:03 AM by lotas Filed Under: HowTo, Cool Stuff [...]
Great article!
Thanks a lot, you saved my day. I was going to install some penguin OS just to run the EC2 tools. Never realized Java API is actually cross-platform. Fantastic!