Upload SSH key to AWS using AWS CLI
Region needs to be specified if you want to upload the key to some other region than your default.
My ~/.aws/config
looks like:
[default]
output = json
region = eu-west-1
aws_access_key_id = ...
aws_secret_access_key = ...
Command that uploads the primary key, assuming that the public key is available in ~/.ssh/my-precious.pub
:
aws \
--region us-east-1 \
ec2 import-key-pair \
--key-name my-precious \
--public-key-material "$(cat ~/.ssh/my-precious.pub)"
Output, in JSON because of the config's format directive:
{
"KeyName": "my-precious",
"KeyFingerprint": "aa:bb:cc..."
}
Written by Simon Pantzare
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Ssh
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#