导入密钥对
更新时间:2024-10-17
该接口用于用户自行导入创建密钥对。 请求参数中导入的密钥对仅支持以下加密方式: - rsa - dsa - ssh-rsa - ssh-dss - ecdsa
请求结构
Plain Text
1PUT /v{version}/keypair?{action} HTTP/1.1
2Host: bcc.bj.baidubce.com
3Authorization: authorization string
4
5{
6 "name": "keypair01",
7 "description": "some description",
8 "publicKey": "your-pulicKey"
9}
请求头域
除公共头域外,无其它特殊头域。
请求参数
参数名称 | 类型 | 是否必需 | 参数位置 | 描述 |
---|---|---|---|---|
version | String | 是 | URL参数 | API版本号 |
action | String | 是 | Query参数 | 对密钥对执行的操作,当前取值:import |
name | String | 是 | RequestBody | 待创建的密钥对名称,只支持大小写字母、数字、汉字以及-_ /.特殊字符,必须以字母开头,长度1-65。 |
description | String | 否 | RequestBody | 待创建的密钥对的描述 |
publicKey | String | 是 | RequestBody | 公钥内容 |
返回头域
除公共头域,无其它特殊头域。
返回参数
参数名称 | 类型 | 描述 |
---|---|---|
keypair | KeypairModel | 密钥对对象 |
错误码
错误码 | 错误描述 | HTTP状态码 | 中文解释 |
---|---|---|---|
Keypair.KeypairNameInvalid | Keypair name is invalid. | 400 | 密钥对名称格式不正确 |
Keypair.KeypairDescriptionInvalid | Keypair description is invalid. | 400 | 密钥对描述格式不正确 |
Keypair.KeypairQuotaExceedLimit | Keypair number exceeds the limit. | 413 | 密钥对数目超限 |
Keypair.KeypairPublicKeyExist | Keypair already exist. | 400 | 公钥已存在 |
Keypair.PublicKeyFormatInvalid | Public key format is invalid. | 400 | 公钥格式不正确 |
请求示例
Plain Text
1POST /v2/keypair?import HTTP/1.1
2Host: bcc.bj.baidubce.com
3Authorization: bce-auth-v1/f81d3b34e48048fbb2634dc7882d7e21/2015-08-11T04:17:29Z/3600/host/74c506f68c65e26c633bfa104c863fffac5190fdec1ec24b7c03eb5d67d2e1de
4{
5 "name": "keypair01",
6 "description": "some description",
7 "publicKey": "your-publicKey"
8}
返回示例
Plain Text
1HTTP/1.1 200 OK
2x-bce-request-id: 1214cca7-4ad5-451d-9215-71cb844c0a50
3Date: Wed, 03 Dec 2014 06:42:19 GMT
4Content-Type: application/json;charset=UTF-8
5Server: BWS
6{
7 "keypair":{
8 "instanceCount":0,
9 "name":"keypair01",
10 "description":"from import",
11 "createdTime":"2019-01-30T11:52:41Z",
12 "publicKey":"publicKey",
13 "fingerPrint":"fingerPrint",
14 "regionId":"bj",
15 "keypairId":"keypairId"
16 }
17}