Managing Multiple SSH Private Keys From One Linux Client

Managing Multiple SSH Private Keys From One Linux Client

Managing Multiple SSH Private Keys From One Linux Client

PROBLEM: Managing Multiple SSH private keys from one Linux client.

SOLUTION: Create local SSH config file.

Managing multiple SSH private keys in Windows is a trivial task with PuTTY. But how do you manage multiple private SSH keys on Linux or Mac OS X? This tutorial by Mitchell Anicas, walks you through connecting to a single server, but what if you need to manage more than one, each with their own unique private SSH keys? This article helped, but I’ll try to articulate it better.

Rename and copy private keys:

Give each of your SSH private keys a meaningful name and copy them to your local ssh directory.

Create an SSH config file:

The config file will associate the individual private keys with the specified hosts.

Connect to remote server:

Then, just issue the friendly name for your host and it will automatically resolve to the specified host in the config file.

If you added a passphrase to your private SSH key for another layer of security, you will be prompted to enter it now.

If you receive the following error: “WARNING: UNPROTECTED PRIVATE KEY FILE,” then you just need to tighten security on the key file. The How-To Geek has some more examples about openssh errors and fixing permissions.

Save and close the file.

If you recognize the key fingerprint as your own, you can safely authenticate the host by entering “yes” when it asks if you want to continue connecting.