How to do it...

  1. Create the key pair, and save it to disk:
      aws ec2 create-key-pair \
--key-name MyEC2KeyPair \
--query 'KeyMaterial' \
--output text > ec2keypair.pem
  1. Change the permissions on the created file:
        chmod 600 ec2keypair.pem