-
Notifications
You must be signed in to change notification settings - Fork 63.1k
Multiple deploy keys #501
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Multiple deploy keys #501
Changes from 15 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
08657ac
Update managing-deploy-keys.md
tarrenj 35d5313
Update managing-deploy-keys.md
tarrenj 6ceecfa
Update managing-deploy-keys.md
tarrenj 3893932
Merge branch 'main' into multiple-deploy-keys
tarrenj efbe8eb
Merge branch 'main' into multiple-deploy-keys
tarrenj f5dbe78
Merge branch 'main' into multiple-deploy-keys
tarrenj 2671463
Merge branch 'main' into multiple-deploy-keys
tarrenj 77e6f3d
Merge branch 'main' into multiple-deploy-keys
tarrenj dfdccd5
Added some edits to draft
martin389 218625f
Merge branch 'main' into multiple-deploy-keys
martin389 1931771
Some small fixes
martin389 69b5545
Rephrased example sentence
martin389 adf8a75
Merge branch 'main' into multiple-deploy-keys
tarrenj 03eeb42
Merge branch 'main' into multiple-deploy-keys
tarrenj 384fa93
Merge branch 'main' into multiple-deploy-keys
tarrenj b7bfb89
Apply suggestions from code review
martin389 b6417be
Rephrasing for easier compatibility
martin389 ae8805a
Added versioning for GHES
martin389 0564ab2
Merge branch 'main' into multiple-deploy-keys
martin389 eca5ebb
Small edit
martin389 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -83,6 +83,32 @@ See [our guide on Git automation with tokens][git-automation]. | |
7. Select **Allow write access** if you want this key to have write access to the repository. A deploy key with write access lets a deployment push to the repository. | ||
8. Click **Add key**. | ||
|
||
##### Using multiple repositories on one server | ||
|
||
If you use multiple repositories on one server, you will need to generate a dedicated key pair for each one. You can't reuse a deploy key for multiple repositories. | ||
|
||
In the server's SSH configuration file (usually `~/.ssh/config`), add an alias entry for each repository. For example: | ||
|
||
```bash | ||
Host mygithub.libinneed.workers.dev-repo-0 | ||
Hostname github.com | ||
IdentityFile=/home/user/.ssh/repo-0_deploy_key | ||
|
||
Host mygithub.libinneed.workers.dev-repo-1 | ||
Hostname github.com | ||
IdentityFile=/home/user/.ssh/repo-1_deploy_key | ||
``` | ||
|
||
* `Host mygithub.libinneed.workers.dev-repo-0` - The repository's alias. | ||
* `Hostname github.com` - Configures the alias to use the {% data variables.product.product_name %} server. | ||
* `IdentityFile=/home/user/.ssh/repo-0_deploy_key` - Assigns a private key to the alias. | ||
|
||
With these entries added, you can then use the alias to clone a repository, and the unique deploy key is automatically presented. For example: | ||
martin389 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
```bash | ||
$ git clone [email protected]:github-user/repo-1.git | ||
martin389 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
``` | ||
martin389 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
### Machine users | ||
|
||
If your server needs to access multiple repositories, you can create a new {% data variables.product.product_name %} account and attach an SSH key that will be used exclusively for automation. Since this {% data variables.product.product_name %} account won't be used by a human, it's called a _machine user_. You can add the machine user as a [collaborator][collaborator] on a personal repository (granting read and write access), as an [outside collaborator][outside-collaborator] on an organization repository (granting read, write, or admin access), or to a [team][team] with access to the repositories it needs to automate (granting the permissions of the team). | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.