You need to enable JavaScript to run this app.
文档中心
云服务器

云服务器

复制全文
下载 pdf
密钥对
ImportKeyPair - 导入密钥对
复制全文
下载 pdf
ImportKeyPair - 导入密钥对
调用 ImportKeyPair 导入由其他工具产生的密钥对的公钥。您在同一地域内最多可创建500个密钥对。​
调试​
API Explorer
您可以通过 API Explorer 在线发起调用,无需关注签名生成过程,快速获取调用结果。
​
请求参数​
下方仅列出该接口特有的请求参数和部分公共参数。更多信息请见公共参数。​
Action string 必选 示例值:ImportKeyPair​
要执行的操作,取值:ImportKeyPair。​
​
Version string 必选 示例值:2020-04-01​
API的版本,取值:2020-04-01。​
​
ClientToken string 可选 示例值:333456899ff****​
保证请求幂等性。由客户端自动生成一个参数值,确保不同请求间该参数值唯一,避免当调用API超时或服务器内部错误时,客户端多次重试导致重复性操作。​
取值:仅支持ASCII字符,且不能超过64个字符。​
​
Description string 可选 示例值:ssh_key_pair description​
密钥对的描述。​
  • 必须以字母或中文开头。​
  • 只能包含中文、字母、数字、点“.”、空格、下划线“_”、中划线“-”、等号“=”、英文逗号“,”、中文逗号“,”和中文句号“。”​
  • 长度限制在255个字符以内。​
​
KeyPairName string 必选 示例值:ssh_key_pair​
密钥对名称。​
  • 不可与已有名称重复。​
  • 长度限制在 2~64 个字符之间。​
  • 允许使用点号“.”分隔字符成多段,每段允许使用大小写字母、数字或连字符“-”。​
  • 不能以“-”和“.”开头或结尾,不能连续使用“-”或者“.”。​
​
ProjectName string 可选 示例值:project_a​
资源所属项目,一个资源只能归属于一个项目。​
  • 只能包含字母、数字、下划线“_”、点“.”和中划线“-”。​
  • 长度限制在64个字符以内。​
​
PublicKey string 必选 示例值:ssh-rsa AaaAAB3NzaC1yc2EAAAADAQ******​
密钥对的公钥信息。​
​
Tags.N.Key string[] 必选 示例值:Tags.1.Key=k1&Tags.2.Key=k2​
用户标签的标签键。​
  • 参数 - N:表示标签键的序号,取值范围:1~20。​
  • 多个标签键之间用&分隔。​
命名规则如下:​
  • 不能以volc:或sys:的任意大小写组合开头。​
  • 只能包含语言字符、数字、空格和英文符号“_”、“.”、“:”、“/”、“=”、“+”、“-”、“@”。​
  • 长度限制在1~128个字符之间。​
说明​
同一资源的标签键不允许重复。​
​
Tags.N.Value string[] 可选 示例值:Tags.1.Value=v1&Tags.2.Value=v2​
用户标签的标签值。​
  • 参数 - N:表示标签值的序号,取值范围:1~20。​
  • 多个标签值之间用&分隔。​
命名规则如下:​
  • 只能包含语言字符、数字、空格和英文符号“_”、“.”、“:”、“/”、“=”、“+”、“-”、“@”。​
  • 允许为空,长度限制在0~256个字符之间。​
说明​
如果传入该参数,则必须先传入Tags.N.Key。​
​
​
​
返回参数​
下方仅列出本接口特有的返回参数。更多信息请参见返回结构。​
FingerPrint string 示例值:4158f40dbc0814eb04f0dcac4e******​
密钥对的指纹。根据RFC4716定义的公钥指纹格式,采用MD5信息摘要算法。​
​
KeyPairId string 示例值:kp-bp67acfmxazb4p****​
密钥对唯一ID。​
​
KeyPairName string 示例值:ssh_key_pair​
密钥对名称。​
​
​
​
请求示例​
​
GET /?Action=ImportKeyPair&Version=2020-04-01&KeyPairName=ssh_key_pair&PublicKey=ssh-rsa AaaAAB3NzaC1yc2EAAAADAQ****** HTTP/1.1​
Host: ecs.cn-beijing.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******"​
}​
}​
​
错误码​
下表为您列举了该接口与业务逻辑相关的错误码。公共错误码请参见公共错误码文档。​
​
状态码​
错误码​
错误信息​
说明​
400​
IdempotentParameterMismatch​
The 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.​
幂等参数不一致。​
400​
InvalidClientToken.Malformed​
The specified ClientToken is malformed.​
指定的ClientToken不合法。​
400​
InvalidKeyPairDescription.Malformed​
The specified KeyPairDescription is malformed.​
指定的密钥对描述不合法。​
400​
InvalidKeyPairName.Malformed​
The specified KeyPairName is malformed.​
指定的密钥对名称不合法。​
400​
InvalidKeyPairPublicKey.Malformed​
The specified KeyPairPublicKey is malformed.​
指定的公钥信息不合法。​
400​
InvalidTagKey.Malformed​
The specified TagKey is malformed.​
指定的标签的键不合法。​
400​
InvalidTagValue.Malformed​
The specified TagValue is malformed.​
指定的标签的值不合法。​
400​
LimitExceeded.MaximumKeyPairs​
You've reached the limit on the number of KeyPairs that you can create.​
创建的密钥对数量超过了最大限制。​
400​
LimitExceeded.MaximumTags​
You've reached the limit on the number of tags that you can create.​
指定的标签数量超过最大限制。​
400​
MissingParameter.KeyPairName​
The required parameter KeyPairName is not supplied.​
密钥对名称不能为空。​
400​
MissingParameter.PublicKey​
The required parameter PublicKey is not supplied.​
密钥对的公钥信息不能为空。​
404​
InvalidProject.NotFound​
The specified Project does not exist.​
指定的Project不存在。​
409​
InvalidKeyPairName.Conflict​
The specified KeyPairName already exists.​
指定的密钥对名称重复。​
409​
InvalidTagKey.Conflict​
The specified TagKey already exists.​
指定的标签键已存在。​
412​
IdempotentProcessing​
The request uses the same client token as a previous one that is still in process.​
先前的幂等请求仍在处理中,请稍后重试。​
412​
OperationDenied.ResourceLocked​
The specified operation is denied as your resource is locked for another operation.​
指定的操作被拒绝,因为您的资源已被其他操作锁定。​
500​
InternalError​
An internal error has occurred.​
内部错误,请重试。如果多次尝试失败,请提交工单。​
​
​
最近更新时间:2025.09.04 16:59:40
这个页面对您有帮助吗?
有用
有用
无用
无用