Skip to content

Instantly share code, notes, and snippets.

@jbutko
Last active March 17, 2022 09:21
Show Gist options
  • Select an option

  • Save jbutko/b20a12c62b506737db82ff96f6449bb2 to your computer and use it in GitHub Desktop.

Select an option

Save jbutko/b20a12c62b506737db82ff96f6449bb2 to your computer and use it in GitHub Desktop.
Github - use of github deploy keys

1. Generate ssh key ssh-keygen -t rsa -b 4096 -C "{email}"

2. Rename keys

mv ~/.ssh/id_rsa ~/.ssh/project_x_id_rsa
mv ~/.ssh/id_rsa.pub ~/.ssh/project_x_id_rsa.pub

3. Add public key to "deploy keys"

4. Verify connection: sudo ssh -T git@github.com

5. Edit ssh config file:

  • Edit ssh config file if you use multiple repos on server: sudo nano ~/.ssh/config and add these lines:
Host github.com-project-x
Hostname github.com
IdentityFile=~/.ssh/project_x_id_rsa

6. Clone the repo with custom host: git clone git@github.com-project-x:user/project-x

7. All good.

sources:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment