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
  1. Add public key to "deploy keys" section in your github project https://github.com/user/project-x/settings/keys

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

  1. 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

  1. All good.

sources:

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