All Products
Search
Document Center

Elastic Compute Service:ImportKeyPair

Last Updated:Mar 19, 2024

Imports the public key of a Rivest-Shamir-Adleman (RSA)-encrypted key pair that is generated by a third-party tool. After the public key of the key pair is imported, Alibaba Cloud stores the public key. You are responsible for storing the private key. We recommend that you store it in a safe place.

Operation description

Take note of the following items:

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer.

Authorization information

There is currently no authorization information disclosed in the API.

Request parameters

ParameterTypeRequiredDescriptionExample
RegionIdstringYes

The region ID. You can call the DescribeRegions operation to query the most recent region list.

cn-hangzhou
KeyPairNamestringYes

The name of the key pair. The name must be unique. It must be 2 to 128 characters in length. It must start with a letter and cannot start with http:// or https://. It can contain letters, digits, colons (:), underscores (_), and hyphens (-).

testKeyPairName
PublicKeyBodystringYes

The public key of the key pair.

ABC1234567
ResourceGroupIdstringNo

The ID of the enterprise resource group to which the SSH key pair belongs.

rg-bp67acfmxazb4p****
Tagobject []No

The tags to add to the key pair.

KeystringNo

The key of tag N to add to the key pair. Valid values of N: 1 to 20. The tag key cannot be an empty string. The tag key can be up to 128 characters in length and cannot contain http:// or https://. The tag key cannot start with acs: or aliyun.

TestKey
ValuestringNo

The value of tag N to add to the key pair. Valid values of N: 1 to 20. The tag value can be an empty string. The tag value can be up to 128 characters in length and cannot contain http:// or https://. The tag value cannot start with acs:.

TestValue

Response parameters

ParameterTypeDescriptionExample
object
RequestIdstring

The request ID.

473469C7-AA6F-4DC5-B3DB-A3DC0DE3C83E
KeyPairNamestring

The name of the key pair.

testKeyPairName
KeyPairFingerPrintstring

The fingerprint of the key pair. The MD5 message-digest algorithm is used based on the public key fingerprint format defined in RFC 4716.

89:f0:ba:62:ac:b8:aa:e1:61:5e:fd:81:69:86:6d:6b:f0:c0:5a:**

Examples

Sample success responses

JSONformat

{
  "RequestId": "473469C7-AA6F-4DC5-B3DB-A3DC0DE3C83E",
  "KeyPairName": "testKeyPairName",
  "KeyPairFingerPrint": "89:f0:ba:62:ac:b8:aa:e1:61:5e:fd:81:69:86:6d:6b:f0:c0:5a:**"
}

Error codes

HTTP status codeError codeError messageDescription
400InvalidKeyPairName.MalformedSpecified Key Pair name is not valid.-
400InvalidPublicKeyBody.MalformedThe PublicKeyBody format is not supported.The public key format is not supported.
400MissingParameterThe input parameter "PublicKeyBody" that is mandatory for processing this request is not supplied.-
400KeyPair.AlreadyExistThe key pair already exist.A key pair with the same name already exists. Key pair names must be unique.
403QuotaExceed.KeyPairThe key pair quota exceeds.The maximum number of key pairs has been reached.
404InvalidResourceGroup.NotFoundThe ResourceGroup provided does not exist in our records.The specified resource group does not exist.
500InternalErrorThe request processing has failed due to some unknown error.An internal error has occurred. Try again later.

For a list of error codes, visit the Service error codes.

Change history

Change timeSummary of changesOperation
2023-07-17The Error code has changedsee changesets
Change itemChange content
Error CodesThe Error code has changed.
    delete Error Codes: 400
    delete Error Codes: 403
    delete Error Codes: 404
    delete Error Codes: 500