Home > Net >  How to access two different private repositories created by me
How to access two different private repositories created by me

Time:04-03

i am having trouble pulling from two different private repos. I followed the instructions around here and created a deploy key in my github private repo. I have two private repos of the form:

https://github.com/moonresearch/trading-engine
https://github.com/moonresearch/dbreader

Now, when i went to my dbreader repo, i went to the settings section and added deploy keys from following the following steps:

ssh-keygen -t rsa -b 4096 -C "[email protected]"
eval "$(ssh-agent -s)”
ssh-add ~/.ssh/id_rsa

I then went to my id_rsa.pub file located in ./ssh/id_rsa.pub and copied the contents and pasted into my deploy keys for the repo dbreader. After the above steps, i can successfully do the following:

git clone git ssh://[email protected]/moonresearch/dbreader.git  

Now, when i do the same for the first repo, i am seeing a message "key already in use". Then i created a new key called id_rsa_docker and pasted into the deployment key section for the first repo.

From my understanding here, i am supposed to create a config file in order to manage multiple deploy keys. So i went ahead and created one in ./ssh directory:

Host https://github.com/moonresearch/dbreader
   Hostname github.com
   IdentityFile=/Users/raj/.ssh/id_rsa

Host https://github.com/moonresearch/trading-engine
   Hostname github.com
   IdentityFile=/Users/raj/.ssh/id_rsa_docker

After the above steps, i tried a

git clone git ssh://[email protected]/moonresearch/trading-engine.git

I am still not able to get it to clone properly. Error i am getting is: remote repository not found.

CodePudding user response:

Your ~/.ssh/config file should be:

Host dbreader
   Hostname github.com
   User git
   IdentityFile=/Users/raj/.ssh/id_rsa

Host trading-engine
   Hostname github.com
   User git
   IdentityFile=/Users/raj/.ssh/id_rsa_docker

And your URLs:

git clone dbreader:moonresearch/dbreader.git
git clone trading-engine:moonresearch/trading-engine.git
  • Related