Managing Multiple SSH Keys is becoming more and more important these days due to the PaaS instances and less costly IaaS. Here is how to manage multiple Keys. Plus as most of us needs to use GitHub like repositories, more and more separate identities are becoming a standard need. In this guide we will show the process for Managing Multiple SSH Keys.
Managing Multiple SSH Keys : Preface
We will be use Git as remote (although that part is not needed here) and OS X 10.8.2 with iTerm2 and oh-my-zsh as shell (not bash). Commands will be almost same for Linux. The required setup for iTerm2 on OS X 10.8.2 was written before.
Normally, a single default identity is created for the first time usage and those set appear as id_big-value and id_big-value.pub; where big-value is rsa or dsa. This pair is used for all identification, which might not be relevant (as you will add more and more profiles) later or you want the things to be organized properly. This is why we are taking the pain to create a config file for Managing Multiple SSH Keys.
Managing Multiple SSH Keys : Method
The steps are almost same for Ubuntu and Debian OS, but specifically this is for full OS X Server administration (read Mac OS X 10.8).
First change directory to .ssh :
This is very nice command, you will get a 1024 bit key pair (public and private keys) with no password prompts and many extra things :
ssh-keygen -b 1024 -t dsa -f id_dsa -P ''
If you want 2048 bits, change from 1024. ssh obtains configuration data from the following sources in the following order : command-line options, user’s configuration file ($HOME/.ssh/config), system-wide configuration file (/etc/ssh/ssh_config ).
As the next steps, you will :
cat id_dsa.pub >> authorized_keys2
chmod 400 id_dsa
And finally add for your needed service / git :
As in case of the screnshot, you can see, we got two options to choose from. So this needs to be done first before login to the service.