Skip to main content
We publish frequent updates to our documentation, and translation of this page may still be in progress. For the most current information, please visit the English documentation.

Schlüssel bereitstellen

Verwende die REST-API, um Bereitstellungsschlüssel zu erstellen und zu verwalten.

Informationen zu Bereitstellungsschlüsseln

Du kannst Projekte aus einem Repository in your GitHub Enterprise Server instance auf deinem Server starten, indem du einen Bereitstellungsschlüssel verwendest. Dabei handelt es sich um einen SSH-Schlüssel, der Zugriff auf ein einzelnes Repository gewährt. GitHub Enterprise Server fügt den öffentlichen Teil des Schlüssels direkt an dein Repository anstatt an dein persönliches Konto an, und der private Teil des Schlüssels verbleibt auf deinem Server. Weitere Informationen findest du unter Übermitteln von Bereitstellungen.

Die Bereitstellung von Schlüsseln kann entweder mithilfe der folgenden API-Endpunkte oder über GitHub eingerichtet werden. Informationen zum Einrichten der Bereitstellung von Schlüsseln in GitHub findest du unter Verwalten von Bereitstellungsschlüsseln.

List deploy keys

Works with GitHub Apps

Parameters

Headers
Name, Type, BESCHREIBUNG
acceptstring

Setting to application/vnd.github+json is recommended.

Path parameters
Name, Type, BESCHREIBUNG
ownerstringRequired

The account owner of the repository. The name is not case sensitive.

repostringRequired

The name of the repository. The name is not case sensitive.

Query parameters
Name, Type, BESCHREIBUNG
per_pageinteger

The number of results per page (max 100).

Default: 30

pageinteger

Page number of the results to fetch.

Default: 1

HTTP response status codes

Status codeBESCHREIBUNG
200

OK

Code samples

get/repos/{owner}/{repo}/keys
curl \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ http(s)://HOSTNAME/api/v3/repos/OWNER/REPO/keys

Response

Create a deploy key

Works with GitHub Apps

You can create a read-only deploy key.

Parameters

Headers
Name, Type, BESCHREIBUNG
acceptstring

Setting to application/vnd.github+json is recommended.

Path parameters
Name, Type, BESCHREIBUNG
ownerstringRequired

The account owner of the repository. The name is not case sensitive.

repostringRequired

The name of the repository. The name is not case sensitive.

Body parameters
Name, Type, BESCHREIBUNG
titlestring

A name for the key.

keystringRequired

The contents of the key.

read_onlyboolean

If true, the key will only be able to read repository contents. Otherwise, the key will be able to read and write.

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 response status codes

Status codeBESCHREIBUNG
201

Created

422

Validation failed, or the endpoint has been spammed.

Code samples

post/repos/{owner}/{repo}/keys
curl \ -X POST \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-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

Works with GitHub Apps

Parameters

Headers
Name, Type, BESCHREIBUNG
acceptstring

Setting to application/vnd.github+json is recommended.

Path parameters
Name, Type, BESCHREIBUNG
ownerstringRequired

The account owner of the repository. The name is not case sensitive.

repostringRequired

The name of the repository. The name is not case sensitive.

key_idintegerRequired

The unique identifier of the key.

HTTP response status codes

Status codeBESCHREIBUNG
200

OK

404

Resource not found

Code samples

get/repos/{owner}/{repo}/keys/{key_id}
curl \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ http(s)://HOSTNAME/api/v3/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 }

Delete a deploy key

Works with GitHub Apps

Deploy keys are immutable. If you need to update a key, remove the key and create a new one instead.

Parameters

Headers
Name, Type, BESCHREIBUNG
acceptstring

Setting to application/vnd.github+json is recommended.

Path parameters
Name, Type, BESCHREIBUNG
ownerstringRequired

The account owner of the repository. The name is not case sensitive.

repostringRequired

The name of the repository. The name is not case sensitive.

key_idintegerRequired

The unique identifier of the key.

HTTP response status codes

Status codeBESCHREIBUNG
204

No Content

Code samples

delete/repos/{owner}/{repo}/keys/{key_id}
curl \ -X DELETE \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ http(s)://HOSTNAME/api/v3/repos/OWNER/REPO/keys/KEY_ID

Response

Status: 204