Generate an SSH key pair
- In a terminal execute
ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key : /Users/MY_USERNAME/Git/_Keys/MY_PROJECT/MY_PROJECT_rsa_ci
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Leave the passphrase empty, many systems cannot work with password protected key pairs.
This process will save the key-pair in two files. The private key with no extension, and the public key with the .pub extension.
Create a new service GitHub user account which will have access to the repository
- Create a new email address (GitHub requires unique email addresses for every user)
- Register a new user which will have access to the repository
Upload the public key to the service GitHub account
-
- Log into the GitHub account and select Settings in the drop-down in the upper right corner
- On the left side select SSH and GPG keys
- In the upper right corner select the New SSH key button
- Copy the above generated public key to your clipboard.
On a Mac copy the public key to your clipboard with the commandpbcopy < /Users/MY_USERNAME/Git/_Keys/MY_PROJECT/MY_PROJECT_rsa_ci.pub
- Paste the public key into the textbox
- Log into the GitHub account and select Settings in the drop-down in the upper right corner
Add the service user as a collaborator to the GitHub repository
- Log into the GitHub account that has admin access to the repository
- Navigate to the repository and select Settings
- Select COllaborators & teams
- Enter the username into the search box and click Add collaborator
If you use two-factor authentication in Github
If you use two-factor authentication in your GitHub account, and you need automated access to it, create a Personal Access Token and use it instead of your password. GitHub will not ask you to verify your identity.
Generate a Personal Access Token
-
- Log into your GitHub account
- On the left side select Developer settings
- Select Personal access tokens
- Click the Generate new token button
- Select the repo checkbox
- Copy the token to your clipboard. This is the last time you are able to see the token.
- Save the token at a secure location, and use it instead of your password when you need automated access to your GitHub account.