First, there is nothing wrong with using different keys for different accounts. This is pretty much overkill for interactive shells, but there are legitimate reasons for doing it when you're dealing with other, non-interactive services. For example a few years ago GitHub started allowing stronger SSH keys, while Bitbucket insisted on using weaker ones for a while longer. The right action at the time was to use different keys for accessing GitHub and Bitbucket.
Another example is
rsync. If you're using
rsync for, say, deploying files to a web server then you probably want dedicated SSH keys for it. These allow you to set different permissions than you'd normally use with your interactive account.
Back to your question about managing multiple keys: SSH lets you set different options for different destinations. In order to do that you need to edit a file
~/.ssh/config like this:
Host github.com gist.github.com
~/.ssh/config should have permissions 0600 (I don't remember right now if that's enforced by SSH or not, but it certainly doesn't hurt).
You can, of course, also use the same mechanism for interactive shells, so set things like remote username (if different from the local one), remote port, shorten the hostname, etc. E.g.:
Then you can just run
ssh -p 2222 email@example.com
Wildcards are also allowed:
Read the manual for more details.
Last but not least: don't "do the
eval 'ssh-agent -s' thing". Contrary to the popular belief, there are severe security implications to that. The right way to do it is like this:
(then enter your key passwords when you're prompted). That's all, don't do it key by key, or any other way.
This runs a new shell in which your keys are loaded, and when you want to revoke access you just
exit this shell. If you "do the
eval 'ssh-agent -s' thing" then authentication agents are left running long after you log off, and they can (and eventually will) be used for unauthorized access.
Edit: Try this little experiment:
eval $(ssh-agent -s)
- log off, or kill the terminal
- log in again, or open a new terminal
Nobody's killing these
ssh-agents, they hang around until the next
reboot, ready to be used by the latest malware.