ssh multiple keys
Moving the Key
To organise keys, I simply move my keys into a directory named for their purpose, for example “git” for the git keys.
This leaves me with something like the following layout:
[joe@goblin ~]$ cd .ssh
[joe@goblin .ssh]$ ls -l
total 16
-rw-r--r--. 1 joe joe 407 May 4 22:07 config
drwx------. 2 joe joe 4096 Apr 24 13:27 fedoraproject
drwx------. 2 joe joe 4096 Apr 24 13:20 git
-rw-r--r--. 1 joe joe 2061 May 4 22:06 known_hosts
[joe@goblin .ssh]$ cd git
[joe@goblin git]$ ls -l
total 8
-rw-------. 1 joe joe 1766 Jan 5 2012 id_rsa
-rw-r--r--. 1 joe joe 403 Jan 5 2012 id_rsa.pub
[joe@goblin git]$
So in each of the subfolders you will have id_rsa and id_rsa.pub. Pointing to the Key
The only problem now, is that when ssh searches for a key, it won’t be able to find the one it’s looking for. You need to correctly edit your config file that should be located in your ~/.ssh/ folder. If it isn’t already there, just create a new file.
Mine looks like the following:
Host github.com
User git
Hostname github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/git/id_rsa
Host fedoraproject.org
Hostname fedoraproject.org
PreferredAuthentications publickey
IdentityFile ~/.ssh/fedoraproject/id_rsa
Host fedorapeople.org
Hostname fedorapeople.org
PreferredAuthentications publickey
IdentityFile ~/.ssh/fedoraproject/id_rsa
posted by: Guillermo