This is probably a common issue for people who wants to deploy serveral repository on one VPS or VM.
This is not going to be rocket science.
The first step is to generate your first ssh key, for this type the following command line in your terminal:
ssh-keygen -t rsa -b 4096 -C "firstname.lastname@example.org"
When the command CLI is asking you if you want to use a
passphrase you might want to press
ENTER in order to don't have to type it everytime you will want to pull your repository.
Now copy the content of your public key and add it to Github in your first repository (Settings > Deploy keys).
For example on debian it might be:
Now we can clone our repository via ssh with the following command:
git clone email@example.com:YourGitHubName/repo1.git
The next step is to rename our ssh keys and configure them.
To do this you need to go to the following folder:
~/.ssh by typing:
And now rename your keys:
mv id_rsa id_repo1_rsa mv id_rsa.pub id_repo1_rsa.pub
Now we need to configure our keys in the repo and ssh, to do this type the following command line:
And add the following content:
Host repo1 HostName github.com User git IdentityFile ~/.ssh/id_repo1_rsa IdentitiesOnly yes
In our git folder open the git config and edit like this:
[remote "origin"] # url = firstname.lastname@example.org:YourGitHubName/repo1.git url = "ssh://git@repo1/YourGitHubName/repo1.git"
Congratulation you can now test by typing:
git pull origin master and see that our conifguration is working.
Now you can repeat the following steps for your other repositories and start by generating a new ssh key to use as a deploy key in another repository.
Thanks for your help.