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

CreateKeyPair

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

首次发布时间2022.07.01 09:25:16

调用 CreateKeyPair 接口创建一个密钥对。

说明

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

  • 密钥对创建成功后,系统会为您保管密钥对的公钥部分,私钥文件将自动下载到您的本地,默认文件名为:密钥名称.pem。您只有一次下载私钥的机会,火山引擎不会保存您的私钥,请务必保管好该私钥。

调试

请求参数

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

KeyPairName

String

ssh_key_pair

密钥对名称。

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

Description

String

ssh_key_pair description

密钥对的描述,默认值为空字符串。

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

ProjectName

String

project_a

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

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

ClientToken

String

333456899ff****

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

返回数据

名称类型
示例值
描述

KeyPairName

String

ssh_key_pair

密钥对名称。

PrivateKey

String

-----BEGIN RSA PRIVATE KEY-----\nMIIEogIBAAKCAQEAw7ked3y+qiEoWcGqJB8eK5U+NEzopTrx5zyC4l2QbVc9NFh1\\nx5DQGs5YFvum3EOExdv1RZP1b/+vT4CWaHE7yw8dfYU6WZK/CFFVAsn1855RhPgT******

密钥对私钥信息。

KeyPairIdStringkp-ybqcopwrdwl8j1******密钥对唯一ID。

FingerPrint

String

4158f40dbc0814eb04f0dcac4e******

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

请求示例

GET /?Action=CreateKeyPair&Version=2020-04-01&KeyPairName=ssh_key_pair HTTP/1.1
Host: open.volcengineapi.com
Region: cn-beijing
Service: ecs

返回示例

{
    "ResponseMetadata": {
        "RequestId": "202106111445100102252431000052****",
        "Action": "CreateKeyPair",
        "Version": "2020-04-01",
        "Service": "ecs",
        "Region": "cn-beijing"
    },
    "Result": {
        "KeyPairName": "ssh_key_pair",
        "PrivateKey": "-----BEGIN RSA PRIVATE KEY-----\nMIIEogIBAAKCAQEAw7ked3y+qiEoWcGqJB8eK5U+NEzopTrx5zyC4l2QbVc9NFh1\nx5DQGs5YFvum3EOExdv1RZP1b/+vT4CWaHE7yw8dfYU6WZK/CFFVAsn1855RhPgT******",
        "KeyPairId": "kp-ybqcopwrdwl8j1******",
        "FingerPrint": "4158f40dbc0814eb04f0dcac4e******"
    }
}

错误码

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

400

InvalidKeyPairName.Malformed

The specified KeyPairName is malformed.

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

400InvalidKeyPairDescription.MalformedThe specified KeyPairDescription is malformed.指定的密钥对描述不合法。

400

LimitExceeded.MaximumKeyPairs

You've reached the limit on the number of KeyPairs that you can create.

创建的密钥对数量超过了最大限制。

400InvalidClientToken.MalformedThe specified ClientToken is malformed.指定的ClientToken不合法。
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.内部错误,请重试。如果多次尝试失败,请提交工单。