Using different SSH keys for different hosts
When I’m setting up a new computer, one of the tasks I need to do is set up new SSH keys to access different servers. It’s good practice not to use the same key for different services. Keys are useful so you don’t need to type your credentials in all the time when working on a trusted PC.
Instead of typing something like:
ssh email@example.com I can just simply type
ssh github without being prompted for credentials. Less typing. Win!
After you generate several different keys, you can either add them to the command line when using ssh, but it’s easier just to use the config file (typically found at
Here’s an example config file you might have assuming you have three different projects:
If you have properly installed all of your public keys on the appropriate server, then you should now be able to use the following commands:
Each of these will use different credentials and not know about each other – w00t!
Published on System Code Geeks with permission by Patrick Kua, partner at our SCG program. See the original article here: Using different SSH keys for different hosts
Opinions expressed by System Code Geeks contributors are their own.