Skip to content

Instantly share code, notes, and snippets.

@glarrain
Last active October 4, 2017 21:32

Revisions

  1. glarrain revised this gist Oct 4, 2017. 1 changed file with 7 additions and 1 deletion.
    8 changes: 7 additions & 1 deletion create-ec2-key-and-generate-pem-file.sh
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,13 @@
    #!/usr/bin/env bash

    # Tools:
    # - aws-cli version 1.11.143
    # - jp version 0.1.3 (https://github.com/jmespath/jp)
    # - 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'
  2. glarrain created this gist Oct 4, 2017.
    7 changes: 7 additions & 0 deletions create-ec2-key-and-generate-pem-file.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,7 @@
    #!/usr/bin/env bash

    # - aws-cli version 1.11.143
    # - jp version 0.1.3 (https://github.com/jmespath/jp)

    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'