
上QQ阅读APP看书,第一时间看更新
Generating your ssh keys
By default, Amazon EC2 uses ssh key pairs to give you ssh access to your EC2 instances. You can either generate a key pair in EC2 and download the private key or generate a key yourself using a third-party tool such as OpenSSL and import the public key in EC2. We will use the first method:
$ aws ec2 create-key-pair --key-name EffectiveDevOpsAWS { "KeyMaterial": "-----BEGIN RSA PRIVATE KEY-----
\nMIIEogIBAAKCAQEAo6vZQ0BxnqdfZOSdcI66KRvypX0NwH5IEi6GUw06+ [...] sj4FAZVLp4OpaIeg+DxHaXUMx\njVHiSRmxmXv2NJAaiJr/q4wMq+eUq3WLn/DKbIPWkfB5lqnGF2T/biie7igSvder3xE=\n-----END RSA PRIVATE KEY-----", "KeyName": "EffectiveDevOpsAWS", "KeyFingerprint": "d2:ec:b5:07:af:83:74:4c:9c:5f:d1:3c:37:86:1b:f0:9c:1b:c1:cf" }
The key is located in the KeyMaterial section of the JSON output. Save this output in a file. I recommend copying the output and using echo <paste> > file as this will interpret the \n characters:
$ echo "-----BEGIN RSA PRIVATE KEY-----\nMIIEogIBAAKCAQEAo6vZQ0BxnqdfZOSdcI66KRvypX0NwH5IEi6GUw06+ [...] sj4FAZVLp4OpaIeg+DxHaXUMx\njVHiSRmxmXv2NJAaiJr/q4wMq+eUq3WLn/DKbIPWkfB5lqnGF2T/biie7igSvder3xE=\n-----END RSA PRIVATE KEY-----" > ~/.ssh/EffectiveDevOpsAWS.pem $ chmod 600 ~/.ssh/EffectiveDevOpsAWS.pem