Binding Key Pair

Last updated: 2020-06-05 21:20:07

    Note:

    This is a legacy API which has been hidden and will no longer be updated. We recommend using the new CVM API 3.0 which is standardized and faster.

    1. API Description

    This API (AssociateInstancesKeyPairs) is used to bind a key pair to an instance.

    Domain name for API request: cvm.api.qcloud.com

    • Only Linux instances with a status of STOPPED are supported.
    • When the public key of a key pair is written to the SSH configuration of the instance, user can log in to the instance through the private key of the key pair.
    • If the instance has been bound to a key, the original key will become invalid.
    • If the instance was originally logged in through a password, the password becomes unavailable after the key is bound to the instance.
    • Batch operations are supported. The maximum number of instances in a batch for each request is 100. If any instance that does not allow batch operations exists in the batch, a specific error code is returned.

    2. Input Parameters

    The following request parameter list only provides API request parameters. For other parameters, please see Common Request Parameters.

    Parameter Type Required Description
    Version String Yes API version No., used to identify the API version you are requesting. For the first version of this API, input "2017-03-12".
    InstanceIds.N array of Strings Yes ID(s) of one or more instances you are working with. The maximum number of instances in a batch for each request is 100.

    You can obtain the available instance IDs by either of the following ways:
  • Log in to console to query the instance ID;
  • Obtain the instance ID from the InstanceId field in the returned values of API DescribeInstances.
  • KeyIds.N Array of Strings Yes ID(s) of one or more key pairs you want to bind. The maximum number of key pairs in a batch for each request is 100. The key pair ID is in a format such as skey-11112222.

    You can obtain the available key pair IDs by either of the following ways:
  • Log in to console to query the key pair ID;
  • Obtain the key pair ID from the KeyId field in the returned values of API DescribeKeyPairs.
  • ForceStop Boolean No Whether to perform forced shutdown on the running instance. It is recommended to manually shut down the running instance before resetting the user password. Values:
  • TRUE: Perform a forced shutdown in case of a failure of normal shut-down.
  • FALSE: Do not.

    Default: FALSE.
  • 3. Output Parameters

    Parameter Type Description
    RequestId String Unique request ID. RequestId is returned for each request. In case of a failed call to the API, RequestId needs to be provided when you contact the developer at backend.

    4. Error Codes

    The following error codes only include the business logic error codes for this API. For additional error codes, please see Common Error Codes.

    Error Code Description
    MissingParameter Missing parameter. A required parameter is missing in the request.
    InvalidParameterValue Invalid parameter value. Parameter value is in an incorrect format or is not supported.
    InvalidParameterValue.LimitExceeded The number of parameter values exceeds the limit.
    InvalidInstanceId.NotFound Invalid instance ID. The specified instance ID does not exist.
    InvalidInstanceId.Malformed Invalid instance ID. The specified instance ID is in an incorrect format. For example, ins-1122 indicates an ID length error.
    InvalidInstance.NotSupported This operation is not supported for the instance.
    InvalidKeyPairId.Malformed Invalid key pair ID. The specified key pair ID is in an incorrect format. For example, skey-1122 indicates an ID length error.
    InvalidKeyPairId.NotFound Invalid key pair ID. The specified key pair ID does not exist.
    InternalServerError Internal operation error.

    5. Example

    Input

    https://cvm.api.qcloud.com/v2/index.php?Action=AssociateInstancesKeyPairs
    &Version=2017-03-12
    &InstanceIds.1=ins-1e4r6y8i
    &InstanceIds.2=ins-3e56fg78
    &KeyIds.1=skey-4e5ty7i8
    &<Common request parameters>
    

    Output

    {
        "Response": {
            "RequestId": "6EF60BEC-0242-43AF-BB20-270359FB54A7"
        }
    }
    

    Was this page helpful?

    Was this page helpful?

    • Not at all
    • Not very helpful
    • Somewhat helpful
    • Very helpful
    • Extremely helpful
    Send Feedback
    Help