Skip to content

Instantly share code, notes, and snippets.

@glarrain
Last active October 4, 2017 21:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save glarrain/42ba3285439b93503243f37cf09bdb33 to your computer and use it in GitHub Desktop.
Save glarrain/42ba3285439b93503243f37cf09bdb33 to your computer and use it in GitHub Desktop.
Create EC2 key pair and "generate" PEM file
#!/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