Generate a new EC2 key pair and save the private key.
Section: AMIs and Key Pairs
Create a key pair
bash
bash
aws ec2 create-key-pair --key-name my-key --query 'KeyMaterial' --output text > my-key.pemExplanation
Protect the generated private key file and set strict permissions.
Learn the surrounding workflow
Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.
Related commands
Same sheet · prioritizing AMIs and Key Pairs