You can call this operation to delete one or more SSH key pairs.

Description

After you delete an SSH key pair, take note of the following items:

  • You cannot query the SSH key pair by calling the DescribeKeyPairs operation.
  • If an ECS instance has been bound with this SSH key pair,
    • Alibaba Cloud no longer stores the SSH key pair for you, but the instance can use the SSH key pair normally.
    • When you call the DescribeInstances operation to query instance information, the SSH key pair name (KeyPairNames) is still returned, but without other information.

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer. OpenAPI Explorer dynamically generates the sample code of the operation for different SDKs.

Request parameters

Parameter Type Required Example Description
Action String Yes DeleteKeyPairs

The operation that you want to perform. Set the value to DeleteKeyPairs.

KeyPairNames String Yes ["skp-bp67acfmxazb4ph***", "skp-bp67acfmxazb4pi***", ... "skp-bp67acfmxazb4pk***"]

The names of the SSH key pairs. It can be a JSON array that consists of multiple SSH key pairs. Separate multiple SSH key pair names with commas (,). A maximum of 100 key pair names can be entered.

RegionId String Yes cn-hangzhou

The ID of the region to which the SSH key pair belongs. You can call the DescribeRegions operation to query the most recent region list.

Response parameters

Parameter Type Example Description
RequestId String 473469C7-AA6F-4DC5-B3DB-A3DC0DE3C83E

The ID of the request.

Examples

Sample requests

https://ecs.aliyuncs.com/?Action=DeleteKeyPairs
&RegionId=cn-qingdao
&KeyPairNames=["skp-bp67acfmxazb4ph***", "skp-bp67acfmxazb4pi***", ... "skp-bp67acfmxazb4pk***"]
&<Common request parameters>

Sample success responses

XML format

<DeleteKeyPairsResponse>
      <RequestId>473469C7-AA6F-4DC5-B3DB-A3DC0DE3C83E</RequestId>
</DeleteKeyPairsResponse>

JSON format

{
    "RequestId": "473469C7-AA6F-4DC5-B3DB-A3DC0DE3C83E"
}

Error codes

HTTP status code Error code Error message Description
400 MissingParameter The input parameter "KeyPairNames" that is mandatory for processing this request is not supplied. The error message returned because the required KeyPairNames parameter is not specified.
400 InvalidKeyPairNames.ValueNotSupported The specified parameter "KeyPairNames" is not valid. The error message returned because the KeyPairNames parameter is invalid.
403 InstanceKeyPairLimitExceeded Exceeding the allowed amount of instance which will be deleted. The error message returned because the maximum number of instances from which the SSH key pairs will be deleted has been reached.

For a list of error codes, visit the API Error Center.