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.
Parameter |
Mandatory |
Description |
---|---|---|
project_id |
Yes |
Specifies the project ID. For details about how to obtain the project ID, see Obtaining a Project ID. |
Request Message
- Request parameters
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
Mandatory
Type
Description
keypair
Yes
Object
Specifies the created or imported SSH key pair. For details, see Table 2.
Table 2 keypair field data structure description Parameter
Mandatory
Type
Description
public_key
No
String
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 import to the BMS will fail.
name
Yes
String
Specifies the key pair name.
The new key pair name cannot be the same as an existing one.
- Example request
1
POST https://{ECS Endpoint}/v2.1/bbf1946d374b44a0a2a95533562ba954/os-keypairs
1 2 3 4 5 6
{ "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
Object
Specifies the SSH key pair. For details, see Table 3.
Table 3 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 the public key.
private_key
String
Specifies the private key.
- The information about the private key is contained in the response for creating an SSH key.
- The information about the private key is not contained in the response for importing an SSH key.
user_id
String
Specifies the ID of the user to which the key pair belongs.
- Example response
1 2 3 4 5 6 7 8
{ "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
Returned Values |
Description |
---|---|
200 |
The server has successfully processed the request. |
For details about other returned values, see Status Codes.
Error Codes
See Error Codes.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot