Last active
December 23, 2015 23:49
-
-
Save duggan/6712237 to your computer and use it in GitHub Desktop.
Import public key to all EC2 regions. Required ec2-tools. Dedicated to @whiteley
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# | |
# Imports a public key to all EC2 regions. | |
# | |
# Usage: | |
# sh import-keypair <name> <path> | |
# | |
# Example: | |
# sh import-keypair foo ~/.ssh/foo.pub | |
# | |
if [ "x$1x" = "xx" ] ; then | |
printf "You must specify the keypair name\n" | |
exit 1 | |
fi | |
if [ "x$2x" = "xx" ] ; then | |
printf "You must specify the path to your public key\n" | |
exit 1 | |
fi | |
name=$1 | |
location=$2 | |
regions=$(ec2-describe-regions | cut -f2 | xargs) | |
for region in $regions ; do | |
ec2-import-keypair --region=$region -f $location $name | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment