Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Mites-G/4057e3330eb4cc24f2ebef973b0f4657 to your computer and use it in GitHub Desktop.
Save Mites-G/4057e3330eb4cc24f2ebef973b0f4657 to your computer and use it in GitHub Desktop.
How to configure multiple deploy keys for different private github repositories on the same computer

Generate your first ssh key, for this type the following command line in your terminal:

ssh-keygen -t rsa -b 4096 -C "your@email.com"

Now copy the content of your public key and add it to Github:

cat /home/username/.ssh/id_rsa.pub

Go to the following folder: ~/.ssh by typing: cd ~/.ssh. And 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:

nano ~/.ssh/config

And add the following content:

Host repo1
  HostName github.com
  User git
  IdentityFile ~/.ssh/id_repo1_rsa
  IdentitiesOnly yes

Now we can clone our repository via ssh with the following command:

git clone git@repo1:YourGitHubName/repo1.git
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment