Detaches SSH key pairs from one or multiple Linux-based instances.


When you call this operation, note that:

  • After you detach an SSH key pair, you must restart the instance (RebootInstance) for the operation to take effect.
  • After an SSH key pair is detached from an instance, the account-password authentication method is used by default.


You can use API Explorer to perform debugging. API Explorer allows you to perform various operations to simplify API usage. For example, you can retrieve APIs, call APIs, and dynamically generate SDK example code.

Request parameters

Name Type Required Example Description
InstanceIds String Yes ["d-xxxxxxxxx", "d-yyyyyyyyy", … "d-zzzzzzzzz"]

The IDs of instances from which SSH key pairs are detached. The value can be a JSON array consisting of up to 50 instance IDs. Multiple IDs must be separated by commas (,).

KeyPairName String Yes FinanceJoshuaV26

The SSH key pair names.

RegionId String Yes cn-hangzhou

The ID of the region where an SSH key pair resides. You can call DescribeRegions to view the latest list of Alibaba Cloud regions.

Action String No DetachKeyPair

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

Response parameters

Name Type Example Description
FailCount String 0

The number of instances from which key pairs fail to be detached.

KeyPairName String FinanceJoshuaV26

The name of a key pair.

RequestId String 473469C7-AA6F-4DC5-B3DB-A3DC0DE3C83E

The ID of the request. This parameter is returned regardless of whether the operation is successful.


The result set of detach operation.

 └Code String 200

The operation status code returned. 200 indicates that the operation is successful.

 └InstanceId String i-instanceid1

The ID of an instance.

 └Message String successful

The operation information returned. When the value of code is 200, the value of message is successful.

 └Success String true

The message returned indicating whether the operation is successful.

TotalCount String 2

The total number of instances from which key pairs are detached.


Sample requests
&InstanceIds=["i-xxxxxxx", "i-yyyyyyy"]
&<Common request parameters>

Successful response examples

XML format


JSON format

	"FailCount": 0

Error codes

HTTP status code Error code Error message Description
403 DependencyViolation.WindowsInstance The instance creating is windows, cannot use ssh key pair to login The error message returned when you cannot detach key pairs from the specified Windows-based instance.

View error codes