I have 2 GitHub accounts:
account1
account2
In account2 I'm added as collaborator of a certain repo:
account_notmine/repo_xyz
I've created and added a new ssh key for the second account, and also added it on github.
Host github.com
HostName github.com
User git
IdentityFile ~/.ssh/id_rsa
Host github-new
HostName github.com
User git
IdentityFile ~/.ssh/id_rsa_new
Now, if I try to work on one of my personal repositories of account2, it works fine. But when I try to clone the repo of which I'm a collaborator, it doesn't work.
Basically, all that I'm doing is trying to execute this command:
git clone --bare git@github-new:account_notmine/repo_xyz.git
And the error it gives me is:
Cloning into bare repository 'repo_xyz.git'...
Warning: Permanently added 'github.com,xxx.xxx.xxx.xxx' (RSA) to the list of known hosts.
ERROR: Repository not found.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
What am I doing wrong?
Solved: just by calling my github second account via SSH (ssh -T git@github-new), I discovered that it answered me:
Hi **account1**! You've successfully authenticated, but GitHub does not
# provide shell access.
Then I edited my ssh config file adding the IdentitiesOnly yes statement:
Host github.com
HostName github.com
User git
IdentityFile ~/.ssh/id_rsa
IdentitiesOnly yes
Host github-smartstay
HostName github.com
User git
IdentityFile ~/.ssh/id_rsa_new
IdentitiesOnly yes
Well, it worked.