Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to use the command line interface to get a description of an EC2 instance that I just setup.

I connected to the server via ssh and ran the command ec2-describe-images ami-12345abc. Instead of a description of the instance, I get the following error message

Required option '-K, --private-key KEY' missing (-h for usage)

Any suggestions on how I may resolve this?

share|improve this question

migrated from Jun 1 '11 at 8:07

This question came from our site for professional and enthusiast programmers.

The AWS command-line tools use private keys and certificates to establish your identity, just like the AWS web service APIs do. So you have to pass your private key or certificate with each command. (On a related note, you don't need to connect to an EC2 instance to run the commands. You can run them from any machine with the tools installed and an internet connection.)

It's usually easiest to create a script that sets the private key and certificate in EC2_PRIVATE_KEY and EC2_CERT environment variables. That way, you don't have to specify them explicitly via command-line options each time.

See the documentation below (especially the --private-key and --cert options) for more information. Common Options for API Tools

And as always, be careful not to share your private keys and certificates any more broadly than necessary.

share|improve this answer

Follow the steps to generate private-key and certificate for your AWS account.

Generating Your Aws Private Key & Certificate File

You have two choices:

1.You can export these keys (make sure it is in your bashrc file) and execute the EC2 commands

export EC2_PRIVATE_KEY=$HOME/<where your private key is>/pk-XXXXXXXXXXXXXXXXXXXXXXXXXXXX.pem
export EC2_CERT=$HOME/<where your certificate is>/cert-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.pem
ec2-describe-images ami-12345abc

2.Give the path of private key & certificate file when you execute AWS in CLI

ec2-describe-images \
-C <path-to-certificate-file>/cert-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.pem \
-K <path-to-private-key>/pk-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.pem ami-12345abc

I would suggest to choose option 2, since it always make me remember those important files.

share|improve this answer
That link seems to assume you're using Bamboo. – chris Oct 15 '12 at 16:12
@chris Agree, but creating private-key & certificate-file is independent of Bamboo, so it should still work. – RakeshS Oct 16 '12 at 10:39

The easiest way to provide your access keys to the Amazon EC2 CLI is to set the AWS_ACCESS_KEY and AWS_SECRET_KEY environment variables. First, add the following lines to ~/.bashrc and save the file.

export AWS_ACCESS_KEY=your-aws-access-key-id

export AWS_SECRET_KEY=your-aws-secret-key

After you've updated ~/.bashrc, run the following command:

source ~/.bashrc

To verify that your CLI tools are set up correctly, run the following command:



share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.