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
- 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
- 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
- All good.
sources: