ImportKeyPair

Last updated: 2020-08-14 10:08:55

1. API Description

Domain name for API request: cvm.tencentcloudapi.com.

This API is used to import key pairs.

  • You can use this API to import key pairs to a user account, but the key pairs will not be automatically associated with any instance. You may use AssociasteInstancesKeyPair to associate key pairs with instances.
  • You need to specify the names of the key pairs and the content of the public keys.
  • If you only have private keys, you can convert them to public keys with the SSL tool before importing them.

A maximum of 10 requests can be initiated per second for this API.

Note: This API supports Finance regions. If the common parameter Region is a Finance region, a domain name with the Finance region needs to be specified, for example: cvm.ap-shanghai-fsi.tencentcloudapi.com

We recommend you to use API Explorer
Try it
API Explorer provides a range of capabilities, including online call, signature authentication, SDK code generation, and API quick search. It enables you to view the request, response, and auto-generated examples.

2. Input Parameters

The following request parameter list only provides API request parameters and some common parameters. For the complete common parameter list, see Common Request Parameters.

Parameter Name Required Type Description
Action Yes String Common parameter. The value used for this API: ImportKeyPair.
Version Yes String Common parameter. The value used for this API: 2017-03-12.
Region Yes String Common parameter. For more information, please see the list of regions supported by the product.
KeyName Yes String Key pair name, which can contain numbers, letters, and underscores, with a maximum length of 25 characters.
ProjectId Yes Integer The ID of the project to which the created key pair belongs.

You can retrieve the project ID in two ways:
  • Query the project ID in Project Management.
  • Call DescribeProject and search for projectId in the response.

    If you want to use the default project, specify 0 for the parameter.
  • PublicKey Yes String Content of the public key in the key pair in the OpenSSH RSA format.

    3. Output Parameters

    Parameter Name Type Description
    KeyId String Key pair ID
    RequestId String The unique request ID, which is returned for each request. RequestId is required for locating a problem.

    4. Example

    Example1 Importing a key pair

    Input Example

    GET https://cvm.tencentcloudapi.com/?Action=ImportKeyPair
    &KeyName=operation_key
    &ProjectId=0
    &PublicKey=ssh-rsa XXXXXXXXXXXX== skey_45071
    &<Common request parameters>

    Output Example

    {
      "Response": {
        "KeyId": "skey-4e5ty7i8",
        "RequestId": "6EF60BEC-0242-43AF-BB20-270359FB54A7"
      }
    }

    5. Developer Resources

    API Explorer

    This tool allows online call, signature authentication, SDK code generation and quick search of APIs to greatly improve the efficiency of using TencentCloud APIs.

    SDK

    TencentCloud API 3.0 integrates SDKs that support various programming languages to make it easier for you to call APIs.

    Command Line Interface

    6. Error Code

    The following only lists the error codes related to the API business logic. For other error codes, see Common Error Codes.

    Error Code Description
    InternalServerError Internal error.
    InvalidKeyPair.LimitExceeded The number of key pairs exceeds the limit.
    InvalidKeyPairName.Duplicate Key pair name already exists.
    InvalidKeyPairNameEmpty The key name cannot be empty.
    InvalidKeyPairNameIncludeIllegalChar The key name contains invalid characters. Key names can only contain letters, numbers and underscores.
    InvalidKeyPairNameTooLong The key name cannot exceed 25 characters.
    InvalidParameterValue Invalid parameter value: parameter value is in the wrong format or is not supported.
    InvalidPublicKey.Duplicate Invalid public key: the specified key already exists.
    InvalidPublicKey.Malformed Invalid public key: the specified public key does not meet the OpenSSH RSA format requirements.
    MissingParameter Missing parameter: a required parameter is missing.

    Was this page helpful?

    Was this page helpful?

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