Updated on 2026-06-09 GMT+08:00

Importing SSH Key Pairs in Batches

Function

This API is used to import SSH key pairs in batches. A maximum of 10 records can be selected at a time.

Calling Method

For details, see Calling APIs.

Authorization Information

Each account has all the permissions required to call all APIs, but IAM users must be assigned the required permissions.

  • If you are using role/policy-based authorization, see Permissions Policies and Supported Actions for details on the required permissions.
  • If you are using identity policy-based authorization, no identity policy-based permission required for calling this API.

URI

POST /v3/{project_id}/keypairs/batch-import

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Definition

Project ID. For details, see Obtaining a Project ID.

Constraints

N/A

Range

The value returned by the IAM API is used, which contains 32 characters.

Default Value

N/A

Request Parameters

Table 2 Request header parameters

Parameter

Mandatory

Type

Description

X-Auth-Token

Yes

String

Definition

User token. It can be obtained by calling the IAM API. The value of X-Subject-Token in the response header is the user token.

Constraints

N/A

Range

Obtain the value by calling the IAM API for obtaining the user token.

Default Value

N/A

Table 3 Request body parameters

Parameter

Mandatory

Type

Description

[items]

Yes

Array of CreateKeypairRequestBody objects

Definition

Request body for creating a key pair

Constraints

N/A

Range

N/A

Default Value

N/A

Table 4 CreateKeypairRequestBody

Parameter

Mandatory

Type

Description

keypair

Yes

CreateKeypairAction object

Definition

Parameter in the request body for creating a key pair

Constraints

N/A

Range

N/A

Default Value

N/A

Table 5 CreateKeypairAction

Parameter

Mandatory

Type

Description

name

Yes

String

Definition

SSH key pair name

Constraints

  • The key pair name must be unique.

  • The SSH key pair name can contain at most 255 characters. Only letters, digits, underscores (_), and hyphens (-) are allowed.

Range

N/A

Default Value

N/A

type

No

String

Definition

Key pair type

Constraints

N/A

Range

  • ssh

  • x509

Default Value

ssh

public_key

No

String

Definition

Public key of the key pair

Constraints

N/A

Range

N/A

Default Value

N/A

scope

No

String

Definition

Domain to which the key pair belongs, which can be tenant-level or user-level.

Constraints

N/A

Range

  • domain

  • user

Default Value

user

user_id

No

String

Definition

ID of the user to which the SSH key pair belongs

Constraints

N/A

Range

N/A

Default Value

N/A

key_protection

No

KeyProtection object

Definition

SSH key pair private key management and protection information

Constraints

N/A

Range

N/A

Default Value

N/A

Table 6 KeyProtection

Parameter

Mandatory

Type

Description

private_key

No

String

Definition

Private key of the imported SSH key pair

Constraints

N/A

Range

N/A

Default Value

N/A

encryption

Yes

Encryption object

Definition

How a private key is encrypted and stored

Constraints

N/A

Range

N/A

Default Value

N/A

Table 7 Encryption

Parameter

Mandatory

Type

Description

type

Yes

String

Definition

Encryption type

Constraints

If KMS is unavailable, set this parameter to default.

Range

  • default: Default encryption mode, which applies to sites where KMS is unavailable.

  • kms: KMS encryption mode

Default Value

default

kms_key_name

No

String

Definition

KMS key name

Constraints

  • If type is set to kms, you must enter the KMS key name or ID.

Range

N/A

Default Value

N/A

kms_key_id

No

String

Definition

KMS key ID

Constraints

  • If type is set to kms, you must enter the KMS key name or ID.

Range

N/A

Default Value

N/A

Response Parameters

Status code: 200

Table 8 Response body parameters

Parameter

Type

Description

failed_keypairs

Array of FailedKeypair objects

Definition

List of SSH key pairs that failed to be imported

Range

N/A

succeeded_keypairs

Array of CreateKeypairResponseBody objects

Definition

List of imported SSH key pairs

Range

N/A

Table 9 FailedKeypair

Parameter

Type

Description

keypair_name

String

Definition

SSH key pair name

Range

N/A

failed_reason

String

Definition

Import failure cause

Range

N/A

Table 10 CreateKeypairResponseBody

Parameter

Type

Description

keypair

CreateKeypairResp object

Definition

Response body for creating an SSH key pair

Range

N/A

Table 11 CreateKeypairResp

Parameter

Type

Description

name

String

Definition

SSH key pair name

Range

N/A

type

String

Definition

Key pair type

Range

  • ssh

  • x509

public_key

String

Definition

Public key of the key pair

Range

N/A

private_key

String

Definition

Private key of the key pair

Range

  • When creating an SSH key pair, the response contains the private key information.

  • When importing an SSH key pair, the response does not contain the private key information.

fingerprint

String

Definition

Fingerprint information about an SSH key pair

Range

N/A

user_id

String

Definition

ID of the user to which the SSH key pair belongs

Range

N/A

Example Requests

Import the demo2 and demo3 SSH key pairs in batches.

[ {
  "keypair" : {
    "name" : "demo2",
    "public_key" : "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAA... Generated-by-Nova"
  }
}, {
  "keypair" : {
    "name" : "demo3",
    "public_key" : "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAA... Generated-by-Nova"
  }
} ]

Example Responses

Status code: 200

The SSH key pairs are imported in batches.

{
  "failed_keypairs" : [ {
    "keypair_name" : "demo3",
    "failed_reason" : "{\"error_code\":\"KPS.7004\", \"error_msg\":\"Key pair 'demo3' already exists.\"}"
  } ],
  "succeeded_keypairs" : [ {
    "keypair" : {
      "name" : "demo2",
      "fingerprint" : "SHA256:Wm91+h496cPk5JleSp4RdD2n4Z/5KdlDeD51lmiZ11M",
      "type" : "ssh",
      "public_key" : "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAA... Generated-by-Nova",
      "user_id" : "6c2a33b1b8474d0dbac0a24297127525"
    }
  } ]
}

Status Codes

Status Code

Description

200

The SSH key pairs are imported in batches.

Error Codes

See Error Codes.