Attaches an SSH key pair to up to 30 instances in a single call.
Operation description
You can only attach a key pair to stopped instances.
Specify up to 30 instances per call.
Specify either
KeyPairNameorKeyPairId.We recommend using
KeyPairId, asKeyPairNamewill be deprecated.
Try it now
Test
RAM authorization
Request parameters
Parameter | Type | Required | Description | Example |
KeyPairName | string | No | The key pair name. | test-kp |
| InstanceIds | array | Yes | A list of instance IDs. | ["i-50f8q9mbfjzlkuk9znjglnne3"] |
string | No | The instance ID. | i-xxx | |
KeyPairId | string | No | The unique ID of the key pair. | ssh-xxx |
Response elements
Element | Type | Description | Example |
object | The response object. | ||
RequestId | string | The request ID. | xx-xx-xx-xx |
KeyPairName | string | The key pair name. | ssh-xxx |
FailCount | integer | The number of instances where the attachment failed. | 1 |
TotalCount | integer | The total number of instances in the request. | 3 |
| Results | array<object> | The attachment results for each instance. | |
object | |||
Code | integer | The status code for the operation. A value of | 200 |
InstanceId | string | The instance ID. | i-xxx |
Message | string | The response message. If the | successful |
Success | boolean | Indicates if the operation succeeded for the instance. | true |
KeyPairId | string | The key pair ID. | ssh-xxx |
Examples
Success response
JSON format
{
"RequestId": "xx-xx-xx-xx",
"KeyPairName": "ssh-xxx",
"FailCount": 1,
"TotalCount": 3,
"Results": [
{
"Code": 200,
"InstanceId": "i-xxx",
"Message": "successful",
"Success": true
}
],
"KeyPairId": "ssh-xxx"
}Error codes
HTTP status code | Error code | Error message | Description |
400 | NoPermission | Permission denied. | |
400 | InvalidParameter.%s | The specified field %s invalid. Please check it again. |
See Error Codes for a complete list.
Release notes
See Release Notes for a complete list.