키 배포
REST API를 사용하여 배포 키를 만들고 관리합니다.
키 배포 정보
단일 리포지토리에 대한 액세스 권한을 부여하는 SSH 키인 배포 키를 사용하여 GitHub.com의 리포지토리에서 프로젝트를 시작할 수 있습니다. GitHub는 키의 퍼블릭 부분을 개인 계정 대신 리포지토리에 직접 연결하고 키의 프라이빗 부분은 서버에 남아 있습니다. 자세한 내용은 "배포 제공"을 참조하세요.
배포 키는 다음 API 엔드포인트를 사용하거나 GitHub를 사용하여 설정할 수 있습니다. GitHub에서 배포 키를 설정하는 방법을 알아보려면 "배포 키 관리"을 참조하세요.
List deploy keys
"List deploy keys"에 대한 매개 변수
헤더 |
---|
Name, 형식, 설명 |
accept string Setting to |
경로 매개 변수 |
Name, 형식, 설명 |
owner string 필수The account owner of the repository. The name is not case sensitive. |
repo string 필수The name of the repository. The name is not case sensitive. |
쿼리 매개 변수 |
Name, 형식, 설명 |
per_page integer The number of results per page (max 100). 기본값: |
page integer Page number of the results to fetch. 기본값: |
"List deploy keys"에 대한 HTTP 응답 상태 코드
상태 코드 | Description |
---|---|
200 | OK |
"List deploy keys"에 대한 코드 샘플
curl -L \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>"\
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/OWNER/REPO/keys
Response
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,
"added_by": "octocat",
"last_used": "2022-01-10T15:53:42Z"
}
]
Create a deploy key
You can create a read-only deploy key.
"Create a deploy key"에 대한 매개 변수
헤더 |
---|
Name, 형식, 설명 |
accept string Setting to |
경로 매개 변수 |
Name, 형식, 설명 |
owner string 필수The account owner of the repository. The name is not case sensitive. |
repo string 필수The name of the repository. The name is not case sensitive. |
본문 매개 변수 |
Name, 형식, 설명 |
title string A name for the key. |
key string 필수The contents of the key. |
read_only boolean If 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." |
"Create a deploy key"에 대한 HTTP 응답 상태 코드
상태 코드 | Description |
---|---|
201 | Created |
422 | Validation failed, or the endpoint has been spammed. |
"Create a deploy key"에 대한 코드 샘플
curl -L \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>"\
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/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,
"added_by": "octocat",
"last_used": "2022-01-10T15:53:42Z"
}
Get a deploy key
"Get a deploy key"에 대한 매개 변수
헤더 |
---|
Name, 형식, 설명 |
accept string Setting to |
경로 매개 변수 |
Name, 형식, 설명 |
owner string 필수The account owner of the repository. The name is not case sensitive. |
repo string 필수The name of the repository. The name is not case sensitive. |
key_id integer 필수The unique identifier of the key. |
"Get a deploy key"에 대한 HTTP 응답 상태 코드
상태 코드 | Description |
---|---|
200 | OK |
404 | Resource not found |
"Get a deploy key"에 대한 코드 샘플
curl -L \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>"\
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/OWNER/REPO/keys/KEY_ID
Response
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,
"added_by": "octocat",
"last_used": "2022-01-10T15:53:42Z"
}
Delete a deploy key
Deploy keys are immutable. If you need to update a key, remove the key and create a new one instead.
"Delete a deploy key"에 대한 매개 변수
헤더 |
---|
Name, 형식, 설명 |
accept string Setting to |
경로 매개 변수 |
Name, 형식, 설명 |
owner string 필수The account owner of the repository. The name is not case sensitive. |
repo string 필수The name of the repository. The name is not case sensitive. |
key_id integer 필수The unique identifier of the key. |
"Delete a deploy key"에 대한 HTTP 응답 상태 코드
상태 코드 | Description |
---|---|
204 | No Content |
"Delete a deploy key"에 대한 코드 샘플
curl -L \
-X DELETE \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>"\
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/OWNER/REPO/keys/KEY_ID
Response
Status: 204