根据http://docs.amazonwebservices.com/AWSSecurityCredentials/1.0/AboutAWSCredentials.html#QuickStart说明,
“Use the Amazon EC2 command line tools”需要使用“ X.509 Certificates”,
“Use the Amazon EC2 command line tools”需要使用“ X.509 Certificates”,
http://aws.amazon.com/account/ => › Security Credentials => Access Credentials => .509 Certificates
Create X.509 Certificate ,然后下载
证书:cert-4QRF64MVUC7PCHX4K4IDOJ7PKU6KJXME.pem
私钥:pk-4QRF64MVUC7PCHX4K4IDOJ7PKU6KJXME.pem (要保留好)
将上述两个文件放到ec2-api-tools-1.4.3.0/bin下
【linux下使用】
假设当前目录为/root/aws
yum install java #需要java
unzip ec2-api-tools.zip
cd /root/aws/ec2-api-tools-1.4.3.0
cd bin
vi run.sh #run.sh内容如下
###begin of run.sh###
#用法 ./run.sh
ec2-describe-images -a
# ec2-get-console-output i-506f723f -K
pk-4QRF64MVUC7PCHX4K4IDOJ7PKU6KJXME.pem -C
cert-4QRF64MVUC7PCHX4K4IDOJ7PKU6KJXME.pem
#rem ec2-describe-instances -K pk-4QRF64MVUC7PCHX4K4IDOJ7PKU6KJXME.pem -C cert-4QRF64MVUC7PCHX4K4IDOJ7PKU6KJXME.pem
#
export JAVA_HOME=/usr/lib/jvm/jre
export EC2_HOME=/root/aws/ec2-api-tools-1.4.3.0
export EC2_PRIVATE_KEY=pk-4QRF64MVUC7PCHX4K4IDOJ7PKU6KJXME.pem
export EC2_CERT=cert-4QRF64MVUC7PCHX4K4IDOJ7PKU6KJXME.pem
#
./$1 $2 $3 $4 $5
#rem ec2-describe-instances -K pk-4QRF64MVUC7PCHX4K4IDOJ7PKU6KJXME.pem -C cert-4QRF64MVUC7PCHX4K4IDOJ7PKU6KJXME.pem
#
export JAVA_HOME=/usr/lib/jvm/jre
export EC2_HOME=/root/aws/ec2-api-tools-1.4.3.0
export EC2_PRIVATE_KEY=pk-4QRF64MVUC7PCHX4K4IDOJ7PKU6KJXME.pem
export EC2_CERT=cert-4QRF64MVUC7PCHX4K4IDOJ7PKU6KJXME.pem
#
./$1 $2 $3 $4 $5
###end of run.sh###
/root/aws/ec2-api-tools-1.4.3.0/bin下运行
./run.sh ec2-describe-images -a
看到如下结果,表示成功
【dos下使用】
需要java支持,到http://www.oracle.com/technetwork/java/javase/downloads/index.html下载并安装jdk先
解压ec2-api-tools.zip到d:\ec2-api-tools-1.4.3.0
D:\ec2-api-tools-1.4.3.0\bin下建立run.bat,内容如下
rem begin of run.bat
rem 用法 ./run.bat ec2-describe-images
-a
set
JAVA_HOME=D:\Progra~1\Java\jdk1.6.0_24
set EC2_HOME=D:\ec2-api-tools-1.4.3.0
set EC2_PRIVATE_KEY=pk-4QRF64MVUC7PCHX4K4IDOJ7PKU6KJXME.pem
set EC2_CERT=cert-4QRF64MVUC7PCHX4K4IDOJ7PKU6KJXME.pem
%1 %2 %3 %4 %5
rem end of run.bat
set EC2_HOME=D:\ec2-api-tools-1.4.3.0
set EC2_PRIVATE_KEY=pk-4QRF64MVUC7PCHX4K4IDOJ7PKU6KJXME.pem
set EC2_CERT=cert-4QRF64MVUC7PCHX4K4IDOJ7PKU6KJXME.pem
%1 %2 %3 %4 %5
rem end of run.bat
d:\ec2-api-tools-1.4.3.0\bin
下运行
run.bat
ec2-describe-images -a
【cygwin下使用】
假设cygwin安装在d:\cygwin下
启动cygwin,当前目录为/home/administrator/aws
下载http://s3.amazonaws.com/ec2-downloads/ec2-api-tools.zip 到/home/administrator/aws下
解压ec2-api-tools.zip到/home/administrator/aws/ec2-api-tools-1.4.3.0
在/home/administrator/aws/ec2-api-tools-1.4.3.0下建立run.sh,内容如下:
#begin of run.sh
#用法 ./run.sh ec2-describe-images -a
export JAVA_HOME=D:\\Progra~1\\Java\\jdk1.6.0_24
export EC2_HOME=/home/Administrator/aws/ec2-api-tools-1.4.3.0
export EC2_PRIVATE_KEY=pk-4QRF64MVUC7PCHX4K4IDOJ7PKU6KJXME.pem
export EC2_CERT=cert-4QRF64MVUC7PCHX4K4IDOJ7PKU6KJXME.pem
./$1 $2 $3 $4 $5
#end of run.sh
/home/administrator/aws/ec2-api-tools-1.4.3.0/bin下运行
export JAVA_HOME=D:\\Progra~1\\Java\\jdk1.6.0_24
export EC2_HOME=/home/Administrator/aws/ec2-api-tools-1.4.3.0
export EC2_PRIVATE_KEY=pk-4QRF64MVUC7PCHX4K4IDOJ7PKU6KJXME.pem
export EC2_CERT=cert-4QRF64MVUC7PCHX4K4IDOJ7PKU6KJXME.pem
./$1 $2 $3 $4 $5
#end of run.sh
/home/administrator/aws/ec2-api-tools-1.4.3.0/bin下运行
./run.sh ec2-describe-images -a