• Bare Metal Server

bms
  1. Help Center
  2. Bare Metal Server
  3. API Reference
  4. API
  5. BMS SSH Key Pair Management (Native OpenStack APIs)
  6. Creating and Importing an SSH Key Pair (Native OpenStack API)

Creating and Importing an SSH Key Pair (Native OpenStack API)

Function

This interface is used to create an SSH key pair or import a public key to generate a key pair.

After an SSH key is created, download the private key to a local directory. Then, you can use this private key to log in to the BMS. To ensure BMS security, the private key can be downloaded only once. Keep it secure.

URI

POST /v2.1/{project_id}/os-keypairs

Table 1 lists the parameters.

Table 1 Parameter description

Parameter

Mandatory

Description

project_id

Yes

Specifies the project ID.

Request Message

  • Request parameters
    NOTE:

    When creating an SSH key pair, you only need to configure name. When importing a public SSH key, you must also configure public_key.

    Parameter

    Type

    Mandatory

    Description

    keypair

    Dictionary data structure. For details, see [1] keypair field data structure description.

    Yes

    Specifies information about the created SSH key pair or imported public SSH key.

    [1] keypair field data structure description

    Parameter

    Type

    Mandatory

    Description

    public_key

    String

    No

    Specifies the imported public key. The maximum size of the imported public key is 1024 bytes.

    Note: If the length of the public key to be imported exceeds 1024 bytes, the public key importing operation will fail.

    name

    String

    Yes

    Specifies the key pair name.

    The new key pair name cannot be the same as an existing one.

  • Example request
    {
        "keypair": {
            "name": "keypair-7d7c3650-dabe-4eb0-b904-5c464453c043",
            "public_key": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQC9mC3WZN9UGLxgPBpP7H5jZMc6pKwOoSgre8yun6REFktn/Kz7DUt9jaR1UJyRzHxITfCfAIgSxPdGqB/oF1suMyWgu5i0625vavLB5z5kC8Hq3qZJ9zJO1poE1kyD+htiTtPWJ88e12xuH2XB/CZN9OpEiF98hAagiOE0EnOS5Q== Generated by Nova\n"
        }
    }

Response Message

  • Response parameters

    Parameter

    Type

    Description

    keypair

    Dictionary data structure [1]

    Specifies information about the SSH key pair.

    [1] keypair field data structure description

    Parameter

    Type

    Description

    fingerprint

    String

    Specifies fingerprint information about the key pair.

    name

    String

    Specifies the key pair name.

    public_key

    String

    Specifies information about the public key in the key pair.

    private_key

    String

    Specifies information about the private key.

    user_id

    String

    Specifies the ID of the user to which the key pair belongs.

  • Example response
    {
        "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

See section Common Returned Values.