ImportKeyPair

1. API Description

The API is used to import an SSH key pair to log in to a Linux instance.

Note

  • This request is to import an SSH key pair to be used for later instance login.

  • A key pair name and several public SSH keys are required.

2. Input Parameters

The following request parameter list only provides API request parameters.

Parameter Name
Required
Type
Description

keyName

Yes

String

Key pair name.

Up to 32 characters in length are supported, containing letters, digits and special character -_ The names cannot be duplicated.

For example: my_key, my-key

publicKey

Yes

String

Public SSH keys in OpenSSH format. Up to 5 public keys are allowed, separated by pressing ENTER key. For example: ssh-rsa XXXXXXXXXXXX key

keyDescription

No

String

Description of key pair. Up to 255 characters in length are allowed.

3. Output Parameters

Parameter Name
Type
Description

requestId

String

The unique request ID, which is returned for each request. RequestId is required for locating a problem.

keyId

String

Key pair ID.

4. Code Example

Import an SSH key pair.

POST /api/v2/vm HTTP/1.1
Host: console.zenlayer.com
Content-Type: application/json
X-ZC-Action: ImportKeyPair
<Common Request Params>

Request:
{
    "KeyName": "my-key",
    "PublicKey": "ssh-rsa XXXXXXXXXXXX== example"
}

Response:
{
  "requestId": "T69E37B61-4E39-4461-A2BB-205F847D1D60",
  "response": {
    "requestId": "T69E37B61-4E39-4461-A2BB-205F847D1D60",
    "keyId": "key-xxxxx"
  }
}

5. Developer Resources

Zenlayer Cloud API 2.0 integrates SDKs to make it easier for you to call APIs. More programming languages will be supported.

6. Error Codes

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

HTTP Status Code
Error Code
Description

400

INVALID_KEY_NAME_MALFORMED

Key pair name error.

400

INVALID_PUBLIC_KEY_MALFORMED

Public key format error.

400

INVALID_KEY_PAIR_EXCEED_LIMIT

Quota limit exceeded.

409

INVALID_KEY_PAIR_NAME_EXIST

Key pair name duplicated.

Last updated