You need to enable JavaScript to run this app.
导航

ImportKeyPair

最近更新时间2023.11.20 10:48:35

首次发布时间2022.07.01 09:24:57

调用 ImportKeyPair 接口导入由其他工具产生的密钥对的公钥。

说明

您在同一地域内最多可创建500个密钥对。

调试

请求参数

名称类型是否必填示例值描述
ActionStringImportKeyPair要执行的操作,取值:ImportKeyPair。
VersionString2020-04-01API的版本,取值:2020-04-01。

KeyPairName

String

ssh_key_pair

密钥对名称。

  • 不可与已有名称重复。
  • 长度限制在 2~64 个字符之间。
  • 允许使用点号 "." 分隔字符成多段,每段允许使用大小写字母、数字或连字符 "-"。
  • 不能以"-" 和 "."开头或结尾,不能连续使用 "-" 或者 "." 。

PublicKey

String

ssh-rsa AaaAAB3NzaC1yc2EAAAADAQ******

密钥对的公钥信息。

Description

String

ssh_key_pair description

密钥对的描述。

  • 必须以字母或中文开头。
  • 只能包含中文、字母、数字、点“.”、空格、下划线“_”、中划线“-”、等号“=”、英文逗号“,”、中文逗号“,”和中文句号“。”
  • 长度限制在255个字符以内。

ProjectName

String

project_a

资源所属项目,一个资源只能归属于一个项目。

  • 只能包含字母、数字、下划线“_”、点“.”和中划线“-”。
  • 长度限制在64个字符以内。

ClientToken

String

333456899ff****

保证请求幂等性。由客户端自动生成一个参数值,确保不同请求间该参数值唯一,避免当调用API超时或服务器内部错误时,客户端多次重试导致重复性操作。

取值:仅支持ASCII字符,且不能超过64个字符。

返回数据

名称类型示例值描述
KeyPairNameStringssh_key_pair密钥对名称。
KeyPairIdStringkp-bp67acfmxazb4p****密钥对唯一ID。
FingerPrintString4158f40dbc0814eb04f0dcac4e******密钥对的指纹,根据RFC4716定义的公钥指纹格式,采用MD5信息摘要算法。

请求示例

GET /?Action=ImportKeyPair&Version=2020-04-01&KeyPairName=ssh_key_pair&PublicKey=ssh-rsa AaaAAB3NzaC1yc2EAAAADAQ****** HTTP/1.1
Host: open.volcengineapi.com
Region: cn-beijing
Service: ecs

返回示例

{
    "ResponseMetadata": {
        "RequestId": "202106111445100102252431000052****",
        "Action": "ImportKeyPair",
        "Version": "2020-04-01",
        "Service": "ecs",
        "Region": "cn-beijing"
    },
    "Result": {
        "KeyPairName": "ssh_key_pair",
        "KeyPairId": "kp-bp67acfmxazb4p****",
        "FingerPrint": "4158f40dbc0814eb04f0dcac4e******"
    }
}

错误码

HttpCode错误码错误信息描述
400MissingParameter.KeyPairNameThe required parameter KeyPairName is not supplied.密钥对名称不能为空。
400MissingParameter.PublicKeyThe required parameter PublicKey is not supplied.密钥对的公钥信息不能为空。

400

InvalidKeyPairName.Malformed

The specified KeyPairName is malformed.

指定的密钥对名称不合法。

400

InvalidKeyPairPublicKey.Malformed

The specified KeyPairPublicKey is malformed.

指定的公钥信息不合法。

400InvalidKeyPairDescription.MalformedThe specified KeyPairDescription is malformed.指定的密钥对描述不合法。
400InvalidClientToken.MalformedThe specified ClientToken is malformed.指定的ClientToken不合法。
400LimitExceeded.MaximumKeyPairsYou've reached the limit on the number of KeyPairs that you can create.创建的密钥对数量超过了最大限制。
400IdempotentParameterMismatchThe request uses the same client token as a previous, but non-identical request. Do not reuse a client token with different requests, unless the requests are identical.幂等参数不一致。
404InvalidProject.NotFoundThe specified Project does not exist.指定的项目不存在。
409InvalidKeyPairName.ConflictThe specified KeyPairName already exists.指定的密钥对名称重复。
412IdempotentProcessingThe request uses the same client token as a previous one that is still in process.先前的幂等请求仍在处理中,请稍后重试。
500InternalErrorAn internal error has occurred.内部错误,请重试。如果多次尝试失败,请提交工单。