Last active
October 4, 2017 21:32
-
-
Save glarrain/42ba3285439b93503243f37cf09bdb33 to your computer and use it in GitHub Desktop.
Create EC2 key pair and "generate" PEM file
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
#!/usr/bin/env bash | |
# Tools: | |
# - aws-cli version 1.11.143 | |
# - jp version 0.1.3 | |
# https://github.com/jmespath/jp | |
# Notes: | |
# - 'sed' pattern | |
# https://stackoverflow.com/questions/13610639/tr-command-how-to-replace-the-string-n-with-an-actual-newline-n/13611446#13611446 | |
aws ec2 create-key-pair --key-name 'my-key' > 'my-key.json' | |
cat 'my-key.json' | jp 'KeyMaterial' | sed 's/\\n/\n/g' > 'my-key.pem' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment