I use an Ubuntu 14.10 distribution, and two private keys, one encrypted (~/.ssh/E.key), and one not encrypted (~/.ssh/NE.key), which I use for accessing two github repositories, respectively, repoE and repoNE.
I use the common trick of aliasing gitbhub.com to two different domains, which are mapped to the respective ssh keys.
Content (only relevant) of ~/.ssh/config:
Host github.com-E
Hostname github.com
IdentityFile ~/.ssh/E.key
Host github.com-NE
Hostname github.com
IdentityFile ~/.ssh/NE.key
Content (only relevant) of local repository configurations:
# /path/to/repoE/.git/config:
[remote "origin"]
url = [email protected]:organizationE/repoE.git
# /path/to/repoNE/.git/config:
[remote "origin"]
url = [email protected]:organizationNE/repoNE.git
I use ssh-add, so that I don't need to type the passphrase for any access to repoE.
The problem is that apparently, only the first key I add is used (I can see the offer from the ssh client log).
This is for example a sample run:
$ ssh-add ~/.ssh/E.key
# I can now access repoE, but not repoNE
$ ssh-add ~/.ssh/NE.key
# Still the same (I can access repoE, but not repoNE)
$ ssh-add -D
$ ssh-add ~/.ssh/NE.key
# I can now access repoNE, but not repoE
$ ssh-add ~/.ssh/E.key
# Still the same (I can access repoNE, but not repoE)