• Native OpenStack API

noa
  1. Help Center
  2. Native OpenStack API
  3. API Reference
  4. Nova
  5. Keypairs
  6. Creating a Key Pair

Creating a Key Pair

Function Description

This interface is used to create a key pair.

The key pair is specified when an ECS is created. This key pair can be used to generate a certificate during login using SSH so that the user can log in to the ECS using the certificate, without entering the password.

Interface Format

Method

URI

Description

POST

/v2/{tenant_id}/os-keypairs

/v2.1/{tenant_id}/os-keypairs

Creates a key pair.

Restrictions

N/A

Expanded Interface

N/A

Request Parameter

Table 1 Request parameters

Parameter

Type

Mandatory

Description

name

String

Yes

Specifies the name of a key pair. The value contains a maximum of 255 characters, including only underscores (_), hyphens (-), digits, and uppercase and lowercase letters.

public_key

String

No

Specifies the public key.

type

String

Yes

Specifies the key type. The value is ssh or x509.

This field is newly added in version 2.2.

Response Parameter

Table 2 Response parameters

Parameter

Type

Mandatory

Description

fingerprint

N/A

Yes

Specifies the fingerprint that is used for identification.

name

String

Yes

Specifies the name of a key pair.

public_key

String

Yes

Specifies the public key.

private_key

String

No

Specifies the private key.

user_id

UUID

Yes

Specifies the user ID.

This field is newly added in version 2.10.

type

String

Yes

Specifies the key type. The value is ssh or x509.

This field is newly added in version 2.2.

Request Example

POST /v2/6fbe9263116a4b68818cf1edce16bc4f/os-keypairs
POST /v2.1/6fbe9263116a4b68818cf1edce16bc4f/os-keypairs
{
    "keypair": {

        "name": "keypair-7d7c3650-dabe-4eb0-b904-5c464453c043",

        "public_key": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQC9mC3WZN9UGLxgPBpP7H5jZMc6pKwOoSgre8yun6REFktn/Kz7DUt9jaR1UJyRzHxITfCfAIgSxPdGqB/oF1suMyWgu5i0625vavLB5z5kC8Hq3qZJ9zJO1poE1kyD+htiTtPWJ88e12xuH2XB/CZN9OpEiF98hAagiOE0EnOS5Q== Generated by Nova\n"
    }
}

Response Example

{
    "keypair": {
        "public_key": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQC9mC3WZN9UGLxgPBpP7H5jZMc6pKwOoSgre8yun6REFktn/Kz7DUt9jaR1UJyRzHxITfCfAIgSxPdGqB/oF1suMyWgu5i0625vavLB5z5kC8Hq3qZJ9zJO1poE1kyD+htiTtPWJ88e12xuH2XB/CZN9OpEiF98hAagiOE0EnOS5Q== Generated by Nova\n",
        "user_id": "f882feb345064e7d9392440a0f397c25",
        "name": "keypair-7d7c3650-dabe-4eb0-b904-5c464453c043",
        "fingerprint": "35:9d:d0:c3:4a:80:d3:d8:86:f1:ca:f7:df:c4:f9:d8"
    }
}

Returned Values

For details, see section General Request Returned Values.

Error Code

For details, see section General Request Returned Values.