Reputation: 62466
I have two private GitHub repositories and two respective deploy keys on them with write access. For the first repository everything works well but for the second I always obtain:
ERROR: Repository not found.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
If I check my loaded keys with:
ssh-add -E md5 -l
I can see that the fingerprints of the two keys are the same that in their respective GitHub Deploy keys page. So why I cannot push to the second repository?
Upvotes: 0
Views: 313
Reputation: 38
I had exactly the same problem.
According to Github deploy keys: How do I authorize more than one repository for a single machine?
"Git will use the first matched hostname (ie. github.com), therefore only work properly for the first listed Host in the config file."
I found this solution : https://blog.harveydelaney.com/configuring-multiple-deploy-keys-on-github-for-your-vps/
The procedure is to modify the file .ssh/config to
Host repository-one
Hostname github.com
User git
IdentityFile ~/.ssh/key-one
Host repository-two
Hostname github.com
User git
IdentityFile ~/.ssh/key-two
And change in both repositories in the files .git/config the url of the remote
[email protected]:HarveyD/repository-one.git
by
repository-one:HarveyD/repository-one.git
And then I could do git pull
in both repositories.
Upvotes: 2
Reputation: 62466
If I run:
ssh -T [email protected]
I see that I'm authentified with the deploy key of the first repository.
To push to the second repository, I have to unload all keys with:
ssh-add -D
and add back the key of the second repository.
Then I can push to the second repository.
Upvotes: 0