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