1. Generate ssh key
ssh-keygen -f ~/.ssh/project_x_id_rsa -t rsa -b 4096 -C "{email}"
2. Add public key to "deploy keys" in github
- Add public key to "deploy keys" section in your project's Setting menu: https://github.com/user/project-x/settings/keys
3. Verify connection:
sudo ssh -T [email protected]
4. 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
5. Clone the repo with custom host:
git clone [email protected]:user/project-x.git .
6. All good.
sources: