更新时间:2023-12-26 GMT+08:00
创建及导入SSH密钥对(V2.1)
功能介绍
创建SSH密钥对和导入SSH密钥对,同时可选择对私钥进行托管。
URI
请求消息
创建SSH密钥对时,只需要提交SSH密钥对的name属性。导入SSH密钥对时,才需要提交public_key属性。
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
keypair |
是 |
Object |
创建或导入的SSH密钥对的信息,详情请参见表3。 |
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
public_key |
否 |
String |
导入公钥的字符串信息。 |
name |
是 |
String |
SSH密钥对的名称。 新创建的密钥对名称不能和已有密钥对的名称相同。 SSH密钥对名称由英文字母、数字、下划线、中划线组成,长度不能超过64个字节。 |
user_id |
否 |
String |
SSH密钥对的用户ID。 |
key_protection |
否 |
Object |
SSH密钥对私钥托管与保护,详情请参见表4。 |
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
private_key |
否 |
String |
导入私钥的字符串信息。 |
encryption |
是 |
Object |
对私钥进行加密存储的方式,详情请参见表5。 |
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
type |
是 |
String |
取值范围:“kms”或“default”。
若局点没有kms服务,请填“default”。 |
kms_key_name |
否 |
String |
kms密钥的名称。 若“type”为“kms”,则必须填入kms服务密钥名称。 |
响应消息
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
keypair |
是 |
Object |
SSH密钥对的信息,详情请参见表7。 |
示例
- 创建SSH密钥对
- 创建SSH密钥对请求样例
{ "keypair": { "name": "demo1" } }
- 创建SSH密钥对响应样例
{ "keypair": { "public_key": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCXKzohKbFOqubYNunFNsrEYlk9NEIJIFvbmTe/LTeMzFIPKM53Zu2sYr/uuNcziPkWpFchXdkD+O/Bf2ZzKaR1DYPMWss9TkaqU4RQ7CIBW7ChJF1Qzc1JPRBmKe6e8qs1QBBoS1QvXgSjbuf2Fb1yncSbphmQV8+5KA8xkxz4XdM1/gSAZZ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NpWruXEugXALcfbHiH+peO+3AmwgIqgkOLPLxY1Duw6/miDB8bOfECgYEAw3VO\nl9edXExJvJvSzAopSNmw+ExpUZTgS3L2Pyn21QhfwNHyxPH8fNNKv0/x9ZzBn25U\nUxXTPPbLFV3cq7kfuYFW0OZkh8QjCPDkIE116E2QvacxqkBuW774xr5msfWdxpcp\nwccgWKci1vEHLtqj3RTNMFKcXtj4QrCES4ZsPp0CgYEAhzYYux4LWszd188r0Yxz\nOA0wlIUOlhFqVri02d4hv1sEz/Bphv5eHRwP1pDGFok8NRTCQSa7bsN27uptuksI\n+e8rqKrWFcjMxB9SVrgwSVMZXWeG0uw2oN4p0MDTRyIgs2hbmWQm2Mev6Z6JmWyJ\nQzSFXhDySN4K0NxGAiksGsECgYAJvZTXGFWtPdgG4DUXGgKIsOCS3yv4dtTerbH7\n39l/MFWlRFE242BT0CvPcOp79P3pNhRZt6K5TQs921md7THZisqKypCD+5BLZ8XW\nnkWb+BGYgfaFp4RYaiH3tZFkmPrt5KaeE5BXGq0vzP8wpJC5+cln+RX13BYzLJzL\nLr3COQKBgDJjY0qop3aSG+1tSkMJtOFdb2+qXiqaE+Wxv03SOkPx8LBz+taNz+DE\nR7THDNXSrS85WVc3ozE8hULBX12iIWpr5kb5lRaw3ZgX6wBnSSpdQu49v3nFoGJk\nUWY95pQ/BWQaX0q4KxzRVxup+7gwT5sKFXU+ktFtsGMYoDoSzbZS\n-----END RSA PRIVATE KEY-----\n", "user_id": "e4f380899b1248918f3d37098dc63746", "name": "demo123", "fingerprint": "49:ef:73:2b:9b:7f:2e:0c:58:d3:e3:42:8e:28:04:3b" } }
或{ "error_code": "KPS.XXXX", "error_msg": "XXXX" }
- 创建SSH密钥对请求样例
- 创建SSH密钥对并托管私钥
- 创建SSH密钥对并托管私钥请求样例
{ "keypair": { "name": "demo2", "key_protection": { "encryption": { "type": "kms", "kms_key_name": "demo" } } } }
- 创建SSH密钥对并托管私钥响应样例
{ "keypair": { "public_key": "ssh-rsa AAA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okPVz36pSG\nIWSqHnVKzsbxvw5Da9y69NmpSi2E1wqDaU9IzwnLyQpHnE1nXsWmxNqKTHlDBbnb\nXPGFdcECgYEAxf4IMqYBeBiq+7RVwcTcT4gpApJmywigwMFaaX35E3O53ja8hk1/\n5OCRnvK7yrt9wnWY8DIh8GPJptKzuTb/l/14L4kE1MYm7Gpho5SwXV5BqtjgjfZm\nQVNpWruXEugXALcfbHiH+peO+3AmwgIqgkOLPLxY1Duw6/miDB8bOfECgYEAw3VO\nl9edXExJvJvSzAopSNmw+ExpUZTgS3L2Pyn21QhfwNHyxPH8fNNKv0/x9ZzBn25U\nUxXTPPbLFV3cq7kfuYFW0OZkh8QjCPDkIE116E2QvacxqkBuW774xr5msfWdxpcp\nwccgWKci1vEHLtqj3RTNMFKcXtj4QrCES4ZsPp0CgYEAhzYYux4LWszd188r0Yxz\nOA0wlIUOlhFqVri02d4hv1sEz/Bphv5eHRwP1pDGFok8NRTCQSa7bsN27uptuksI\n+e8rqKrWFcjMxB9SVrgwSVMZXWeG0uw2oN4p0MDTRyIgs2hbmWQm2Mev6Z6JmWyJ\nQzSFXhDySN4K0NxGAiksGsECgYAJvZTXGFWtPdgG4DUXGgKIsOCS3yv4dtTerbH7\n39l/MFWlRFE242BT0CvPcOp79P3pNhRZt6K5TQs921md7THZisqKypCD+5BLZ8XW\nnkWb+BGYgfaFp4RYaiH3tZFkmPrt5KaeE5BXGq0vzP8wpJC5+cln+RX13BYzLJzL\nLr3COQKBgDJjY0qop3aSG+1tSkMJtOFdb2+qXiqaE+Wxv03SOkPx8LBz+taNz+DE\nR7THDNXSrS85WVc3ozE8hULBX12iIWpr5kb5lRaw3ZgX6wBnSSpdQu49v3nFoGJk\nUWY95pQ/BWQaX0q4KxzRVxup+7gwT5sKFXU+ktFtsGMYoDoSzbZS\n-----END RSA PRIVATE KEY-----\n", "user_id": "e4f380899b1248918f3d37098dc63746", "name": "demo123", "fingerprint": "49:ef:73:2b:9b:7f:2e:0c:58:d3:e3:42:8e:28:04:3b" } }
- 创建SSH密钥对并托管私钥请求样例
- 导入SSH密钥对公钥
- 导入SSH密钥对公钥请求样例
{ "keypair": { "public_key": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCyNtFZM04PFxERvZU5OBKTKr3mtRZABe5/+zX81lTgDFCBfq6OXia47M4qXOa3ciBEKKZF+fMfs8U2UNB9aK1R/uORsoEFtxSgZnWG6p4Ct1vnrqwDD934VaDFPEn+h3JeAfvTB+Ag1YQ9zh9uYyE9Z3qZcC9+Ui93BDGdBtQeav4odxdwXcr2mT2jJV0nsocV0O4UcKM8BaIm8eqbcroZEkyxqT3mUoSbmGx1hrngjBsP1ufgwJ6D85LFGQC1SjIOLvsR9i6v41BaLF8/kygvKOh2HlNVSMx38g52sTqoQ/xb3f8vR1VDXliAuD0frrG2Fy5wK4rOAnjuX9nh0bC9 Generated-by-Nova\n", "name": "demo3" } }
- 导入SSH密钥对公钥响应样例
{ "keypair": { "public_key": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCyNtFZM04PFxERvZU5OBKTKr3mtRZABe5/+zX81lTgDFCBfq6OXia47M4qXOa3ciBEKKZF+fMfs8U2UNB9aK1R/uORsoEFtxSgZnWG6p4Ct1vnrqwDD934VaDFPEn+h3JeAfvTB+Ag1YQ9zh9uYyE9Z3qZcC9+Ui93BDGdBtQeav4odxdwXcr2mT2jJV0nsocV0O4UcKM8BaIm8eqbcroZEkyxqT3mUoSbmGx1hrngjBsP1ufgwJ6D85LFGQC1SjIOLvsR9i6v41BaLF8/kygvKOh2HlNVSMx38g52sTqoQ/xb3f8vR1VDXliAuD0frrG2Fy5wK4rOAnjuX9nh0bC9 Generated-by-Nova\n", "user_id": "e4f380899b1248918f3d37098dc63746", "name": "demo1", "fingerprint": "b4:9a:c3:12:c4:90:bf:8e:7a:e2:70:10:c3:00:55:3f" } }
或{ "error_code": "KPS.XXXX", "error_msg": "XXXX" }
- 导入SSH密钥对公钥请求样例
- 导入SSH密钥对公钥并托管私钥
- 导入SSH密钥对公钥并托管私钥请求样例
{ "keypair": { "public_key": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDb26UrW0htRbE/Ygf8EPhzanBCc+5yEhkgmeSb2hTe48YRE5FdJKH6tueyj+vw5guoKjAITLjqZCqffGYXz/7aXpFt244b9tTzh2l43uNtEZC+XZtc6KiBgfWupFI8O2i9YjJqdadsr+4Ad4AtIBbF++qsSJN4YycPX//Gl8ja6AGPy4sdv8DZ40Gr8d+dMQ4pAsnUEtZ3jJ6NLdQU2CE1JhBdg3hbVbeh44gqQtSjhxWaSTlr+NbVxSERtXXpsQWsid6qM1RhqH2+02cqXq5oNs4JLdu56pcTgSO5azTsGYJi6j5qp5BAdjMrFtHjbaeVVWtkO1XQxfpueCJ470lx Generated-by-Nova\n", "name": "demo4", "key_protection": { "private_key": "-----BEGIN RSA PRIVATE KEY-----\nMIIEpQIBAAKCAQEA29ulK1tIbUWxP2IH/BD4c2pwQnPuchIZIJnkm9oU3uPGEROR\nXSSh+rbnso/r8OYLqCowCEy46mQqn3xmF8/+2l6RbduOG/bU84dpeN7jbRGQvl2b\nXOiogYH1rqRSPDtovWIyanWnbK/uAHeALSAWxfvqrEiTeGMnD1//xpfI2ugBj8uL\nHb/A2eNBq/HfnTEOKQLJ1BLWd4yejS3UFNghNSYQXYN4W1W3oeOIKkLUo4cVmkk5\na/jW1cUhEbV16bEFrIneqjNUYah9vtNnKl6uaDbOCS3bueqXE4EjuWs07BmCYuo+\naqeQQHYzKxbR422nlVVrZDtV0MX6bngieO9JcQIDAQABAoIBAAVSEXM1KFGMqDdy\ndeMBviF85+6Tw6d7DKSfVMr4whyKwpZTNOdeJZVdq8nEdd9Eke+l5bets6PofKeT\naR0WaYJ7W2WfNJc0p/6kvkawjixrimcw+LuM3dcUgA+T5nGStnwuzi2JX13f/BCC\n09VDu4lbCVjWAMufCqjyl8wEjFXP0Amhu8fpDvqHuhGvDkoVWRm9vDEeyz71P25K\n/UUs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", "kms_key_name": "testName" } } } }
- 导入SSH密钥对公钥并托管私钥响应样例
{ "keypair": { "public_key": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCyNtFZM04PFxERvZU5OBKTKr3mtRZABe5/+zX81lTgDFCBfq6OXia47M4qXOa3ciBEKKZF+fMfs8U2UNB9aK1R/uORsoEFtxSgZnWG6p4Ct1vnrqwDD934VaDFPEn+h3JeAfvTB+Ag1YQ9zh9uYyE9Z3qZcC9+Ui93BDGdBtQeav4odxdwXcr2mT2jJV0nsocV0O4UcKM8BaIm8eqbcroZEkyxqT3mUoSbmGx1hrngjBsP1ufgwJ6D85LFGQC1SjIOLvsR9i6v41BaLF8/kygvKOh2HlNVSMx38g52sTqoQ/xb3f8vR1VDXliAuD0frrG2Fy5wK4rOAnjuX9nh0bC9 Generated-by-Nova\n", "user_id": "e4f380899b1248918f3d37098dc63746", "name": "demo1", "fingerprint": "b4:9a:c3:12:c4:90:bf:8e:7a:e2:70:10:c3:00:55:3f" } }
或{ "error_code": "KPS.XXXX", "error_msg": "XXXX" }
- 导入SSH密钥对公钥并托管私钥请求样例
状态码
请参考状态码。