Creates an SSH key pair. The system stores the public key and returns the unencrypted private key. The private key is encoded with PEM in the PKCS#8 format. You are responsible for storing the private key and ensuring its confidentiality.
Operation description
Description
In addition to calling CreateKeyPair, you can create a key pair by using a third-party key pair generation tool and call the ImportKeyPair operation to upload the key pair to an Alibaba Cloud region.
A maximum of 500 key pairs can be created in each region. For more information, see Limits .
Debugging
Authorization information
Request parameters
Parameter | Type | Required | Description | Example |
---|---|---|---|---|
RegionId | string | Yes | The ID of the region in which to create the key pair. You can call the DescribeRegions operation to query the most recent region list. | cn-hangzhou |
KeyPairName | string | Yes | The name of the key pair. The name must be 2 to 128 characters in length. It must start with a letter and cannot start with | testKeyPairName |
ResourceGroupId | string | No | The ID of the enterprise resource group to which the SSH key pair belongs. | rg-bp67acfmxazb4p**** |
Tag | object [] | No | The tags. | |
Key | string | No | The key of tag N to be bound to the key pair. Valid values of N: 1 to 20. The tag key cannot be an empty string. The tag key can be up to 128 characters in length and cannot contain | TestKey |
Value | string | No | The value of tag N of the key pair. Valid values of N: 1 to 20. The tag value can be an empty string. The tag value can be up to 128 characters in length and cannot contain http:// or https://. It cannot start with acs:. | TestValue |
Response parameters
Examples
Sample success responses
JSON
format
{
"PrivateKeyBody": "MIIEpAIBAAKCAQEAtReyMzLIcBH78EV2zj****",
"KeyPairName": "testKeyPairName",
"KeyPairId": "ssh-bp67acfmxazb4p****",
"RequestId": "473469C7-AA6F-4DC5-B3DB-A3DC0DE3C83E",
"KeyPairFingerPrint": "89:f0:ba:62:ac:b8:aa:e1:61:5e:fd:81:69:86:6d:6b:f0:c0:5a:**"
}
Error codes
HTTP status code | Error code | Error message | Description |
---|---|---|---|
400 | InvalidKeyPairName.Malformed | Specified Key Pair name is not valid. | - |
400 | KeyPair.AlreadyExist | The key pair already exist. | A key pair with the same name already exists. Key pair names must be unique. |
400 | Duplicate.TagKey | The Tag.N.Key contain duplicate key. | The specified tag key already exists. Tag keys must be unique. |
400 | InvalidTagKey.Malformed | The specified Tag.n.Key is not valid. | The specified Tag.N.Key parameter is invalid. |
400 | InvalidTagValue.Malformed | The specified Tag.n.Value is not valid. | The specified tag value is invalid. |
403 | QuotaExceed.KeyPair | The key pair quota exceeds. | The maximum number of key pairs has been reached. |
403 | QuotaExceed.Tags | %s | The number of specified tags exceeds the upper limit. %s is a variable. An error message is dynamically returned based on call conditions. |
404 | InvalidRegionId.NotFound | The RegionId provided does not exist in our records. | The RegionId provided does not exist |
404 | InvalidResourceGroup.NotFound | The ResourceGroup provided does not exist in our records. | The specified resource group does not exist. |
For a list of error codes, visit the Service error codes.