Follow these steps to create and download a key pair:
- Create the key pair and save it to disk, as follows:
Note that this is intended to be a secret key and must be protected accordingly! Don't store the key in a public place.
aws ec2 create-key-pair
--key-name MyEC2KeyPair
--query 'KeyMaterial'
--output text > ec2keypair.pem
- Change the permissions on the created file:
chmod 400 ec2keypair.pem