ImportKeyPair - 导入RSA密钥对公钥

调用ImportKeyPair导入由其他工具产生的RSA密钥对的公钥部分。导入密钥对后,阿里云为您保管公钥部分,您需要自行妥善保存密钥对的私钥部分。

接口说明

调用该接口时,您需要注意:

  • 您在每个地域的密钥对数最高为 500 对。
  • 导入的密钥对必须支持下列任一种加密方式:
    • rsa
    • dsa
    • ssh-rsa
    • ssh-dss
    • ecdsa
    • ssh-rsa-cert-v00@openssh.com
    • ssh-dss-cert-v00@openssh.com
    • ssh-rsa-cert-v01@openssh.com
    • ssh-dss-cert-v01@openssh.com
    • ecdsa-sha2-nistp256-cert-v01@openssh.com
    • ecdsa-sha2-nistp384-cert-v01@openssh.com
    • ecdsa-sha2-nistp521-cert-v01@openssh.com

调试

您可以在OpenAPI Explorer中直接运行该接口,免去您计算签名的困扰。运行成功后,OpenAPI Explorer可以自动生成SDK代码示例。

授权信息

当前API暂无授权信息透出。

请求参数

名称类型必填描述示例值
RegionIdstring

地域 ID。您可以调用 DescribeRegions 查看最新的阿里云地域列表。

cn-hangzhou
KeyPairNamestring

密钥对名称。必须保持名称唯一性。 长度为 2~128 个英文或中文字符。必须以大小字母或中文开头,不能以 http:// 和 https:// 开头。可以包含数字、半角冒号(:)、下划线(_)或者短划线(-)。

testKeyPairName
PublicKeyBodystring

密钥对的公钥内容。

ABC1234567
ResourceGroupIdstring

SSH 密钥对所在的企业资源组 ID。

rg-bp67acfmxazb4p****
Tagarray<object>

标签列表。

object

标签列表。

Keystring

密钥对的标签键。N 的取值范围:1~20。一旦传入该值,则不允许为空字符串。最多支持 128 个字符,不能以 aliyun 和 acs:开头,不能包含 http://或者 https://。

TestKey
Valuestring

密钥对的标签值。N 的取值范围:1~20。一旦传入该值,允许为空字符串。最多支持 128 个字符,不能以 acs:开头,不能包含 http://或者 https://。

TestValue

返回参数

名称类型描述示例值
object
RequestIdstring

请求 ID。

473469C7-AA6F-4DC5-B3DB-A3DC0DE3C83E
KeyPairNamestring

密钥对名称。

testKeyPairName
KeyPairFingerPrintstring

密钥对的指纹。根据 RFC 4716 定义的公钥指纹格式,采用 MD5 信息摘要算法。

89:f0:ba:62:ac:b8:aa:e1:61:5e:fd:81:69:86:6d:6b:f0:c0:5a:**

示例

正常返回示例

JSON格式

{
  "RequestId": "473469C7-AA6F-4DC5-B3DB-A3DC0DE3C83E",
  "KeyPairName": "testKeyPairName",
  "KeyPairFingerPrint": "89:f0:ba:62:ac:b8:aa:e1:61:5e:fd:81:69:86:6d:6b:f0:c0:5a:**"
}

错误码

HTTP status code错误码错误信息描述
400InvalidKeyPairName.MalformedSpecified Key Pair name is not valid.密钥对名称不合法。
400InvalidPublicKeyBody.MalformedThe PublicKeyBody format is not supported.公钥格式不支持。
400MissingParameterThe input parameter "PublicKeyBody" that is mandatory for processing this request is not supplied.-
400KeyPair.AlreadyExistThe key pair already exist.密钥对已存在,请不要重复添加。
403QuotaExceed.KeyPairThe key pair quota exceeds.密钥对数量已达上限。
404InvalidResourceGroup.NotFoundThe ResourceGroup provided does not exist in our records.资源组并不在记录中。
500InternalErrorThe request processing has failed due to some unknown error.内部错误,请重试。

访问错误中心查看更多错误码。

变更历史

变更时间变更内容概要操作
2023-07-17OpenAPI 错误码发生变更查看变更详情