Creating and Importing an SSH Key Pair
Function
Creating and Importing an SSH Key Pair
Calling Method
For details, see Calling APIs.
URI
POST /v3/{project_id}/keypairs
| 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
| 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 |
| 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 |
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| name | Yes | String | Definition SSH key pair name Constraints
Range N/A Default Value N/A |
| type | No | String | Definition Key pair type Constraints N/A Range 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 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 |
| 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 |
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| type | Yes | String | Definition Encryption type Constraints If KMS is unavailable, set this parameter to default. Range Default Value default |
| kms_key_name | No | String | Definition KMS key name Constraints Range N/A Default Value N/A |
| kms_key_id | No | String | Definition KMS key ID Constraints Range N/A Default Value N/A |
Response Parameters
Status code: 200
| Parameter | Type | Description |
|---|---|---|
| keypair | CreateKeypairResp object | Definition Response body for creating an SSH key pair Range N/A |
| Parameter | Type | Description |
|---|---|---|
| name | String | Definition SSH key pair name Range N/A |
| type | String | Definition Key pair type Range |
| public_key | String | Definition Public key of the key pair Range N/A |
| private_key | String | Definition Private key of the key pair Range |
| 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
{
"keypair" : {
"name" : "demo2"
}
} Example Responses
Status code: 200
Request succeeded.
{
"keypair" : {
"name" : "demo",
"type" : "ssh",
"public_key" : "ssh-rsa AAAAB3NzaC1yc2EAAAADAQAB...",
"private_key" : "-----BEGIN RSA PRIVATE KEY-----...",
"fingerprint" : "49:ef:73:2b:9b:7f:2e:0c:58:d3:e3:42:8e:28:04:3b",
"user_id" : "e4f380899b1248918f3d37098dc63746"
}
} Status Codes
| Status Code | Description |
|---|---|
| 200 | Request succeeded. |
Error Codes
See Error Codes.