aws ec2 create-key-pair
Creates an ED25519 or 2048-bit RSA key pair with the specified name and in the specified format. AWS CLI reference
1 example 5 options Its page in the AWS CLI reference
Examples
To create a key pair
The following create-key-pair example creates a key pair named MyKeyPair.
aws ec2 create-key-pair --key-name MyKeyPairIdentify--key-nameA unique name for the key pair.The output is an ASCII version of the private key and key fingerprint. You need to save the key to a file.
Its output
{
"KeyFingerprint": "1f:51:ae:28:bf:89:e9:d8:1f:25:5d:37:2d:7d:b8:ca:9f:f5:f1:6f",
"KeyMaterial": "-----BEGIN RSA PRIVATE KEY-----\nEXAMPLEKEYMATERIAL\n-----END RSA PRIVATE KEY-----",
"KeyName": "MyKeyPair",
"KeyPairId": "key-0b94643da6EXAMPLE"
}For more information, see Creating, displaying, and deleting Amazon EC2 key pairs in the AWS CLI in the AWS Command Line Interface User Guide.
Options
--dry-runChecks whether you have the required permissions for the action, without actually making the request, and provides an error response.--key-formatThe format of the key pair.--key-nameA unique name for the key pair.--key-typeThe type of key pair.--tag-specificationsThe tags to apply to the new key pair.