此版本的 GitHub Enterprise 已停止服务 2022-06-03. 即使针对重大安全问题,也不会发布补丁。 要获得更好的性能、改进的安全性和新功能,请升级到 GitHub Enterprise 的最新版本。 如需升级方面的帮助,请联系 GitHub Enterprise 支持。
部署密钥
部署密钥 API 允许您创建和管理部署密钥。
关于部署密钥 API
您可以使用部署密钥(授予对单个存储库的访问权限的 SSH 密钥)从 您的 GitHub Enterprise Server 实例 上的存储库启动到服务器的项目。 GitHub Enterprise Server 将密钥的公共部分直接附� 到仓库而不是个人帐户,密钥的私有部分仍保留在服务器上。 更多信息请参阅“交付部署”。
部署密钥可以使用以下 API 端点进行设置,也可以使用 GitHub 进行设置。 要了解如何在 GitHub 中设置部署密钥,请参阅“管理部署密钥”。
List deploy keys
参数
| � �头 |
|---|
| 名称, 类型, 描述 |
acceptstringSetting to |
| 路径参数 |
| 名称, 类型, 描述 |
ownerstring必选The account owner of the repository. The name is not case sensitive. |
repostring必选The name of the repository. The name is not case sensitive. |
| 查询参数 |
| 名称, 类型, 描述 |
per_pageintegerThe number of results per page (max 100). 默认值: |
pageintegerPage number of the results to fetch. 默认值: |
HTTP 响应状态代� �
| 状态代� � | 描述 |
|---|---|
200 | OK |
代� �示例
curl \ -H "Accept: application/vnd.github.v3+json" \ -H "Authorization: token <TOKEN>" \ http(s)://HOSTNAME/api/v3/repos/OWNER/REPO/keysResponse
Status: 200[ { "id": 1, "key": "ssh-rsa AAA...", "url": "https://api.github.com/repos/octocat/Hello-World/keys/1", "title": "octocat@octomac", "verified": true, "created_at": "2014-12-10T15:53:42Z", "read_only": true } ]Create a deploy key
You can create a read-only deploy key.
参数
| � �头 |
|---|
| 名称, 类型, 描述 |
acceptstringSetting to |
| 路径参数 |
| 名称, 类型, 描述 |
ownerstring必选The account owner of the repository. The name is not case sensitive. |
repostring必选The name of the repository. The name is not case sensitive. |
| 正文参数 |
| 名称, 类型, 描述 |
titlestringA name for the key. |
keystring必选The contents of the key. |
read_onlybooleanIf Deploy keys with write access can perform the same actions as an organization member with admin access, or a collaborator on a personal repository. For more information, see "Repository permission levels for an organization" and "Permission levels for a user account repository." |
HTTP 响应状态代� �
| 状态代� � | 描述 |
|---|---|
201 | Created |
422 | Validation failed |
代� �示例
curl \ -X POST \ -H "Accept: application/vnd.github.v3+json" \ -H "Authorization: token <TOKEN>" \ http(s)://HOSTNAME/api/v3/repos/OWNER/REPO/keys \ -d '{"title":"octocat@octomac","key":"ssh-rsa AAA...","read_only":true}'Response
Status: 201{ "id": 1, "key": "ssh-rsa AAA...", "url": "https://api.github.com/repos/octocat/Hello-World/keys/1", "title": "octocat@octomac", "verified": true, "created_at": "2014-12-10T15:53:42Z", "read_only": true }Get a deploy key
参数
| � �头 |
|---|
| 名称, 类型, 描述 |
acceptstringSetting to |
| 路径参数 |
| 名称, 类型, 描述 |
ownerstring必选The account owner of the repository. The name is not case sensitive. |
repostring必选The name of the repository. The name is not case sensitive. |
key_idinteger必选The unique identifier of the key. |
HTTP 响应状态代� �
| 状态代� � | 描述 |
|---|---|
200 | OK |
404 | Resource not found |
代� �示例
curl \ -H "Accept: application/vnd.github.v3+json" \ -H "Authorization: token <TOKEN>" \ http(s)://HOSTNAME/api/v3/repos/OWNER/REPO/keys/KEY_IDResponse
Status: 200{ "id": 1, "key": "ssh-rsa AAA...", "url": "https://api.github.com/repos/octocat/Hello-World/keys/1", "title": "octocat@octomac", "verified": true, "created_at": "2014-12-10T15:53:42Z", "read_only": true }Delete a deploy key
Deploy keys are immutable. If you need to update a key, remove the key and create a new one instead.
参数
| � �头 |
|---|
| 名称, 类型, 描述 |
acceptstringSetting to |
| 路径参数 |
| 名称, 类型, 描述 |
ownerstring必选The account owner of the repository. The name is not case sensitive. |
repostring必选The name of the repository. The name is not case sensitive. |
key_idinteger必选The unique identifier of the key. |
HTTP 响应状态代� �
| 状态代� � | 描述 |
|---|---|
204 | No Content |
代� �示例
curl \ -X DELETE \ -H "Accept: application/vnd.github.v3+json" \ -H "Authorization: token <TOKEN>" \ http(s)://HOSTNAME/api/v3/repos/OWNER/REPO/keys/KEY_IDResponse
Status: 204