David - Musings of an SRE

Store your SSH private keys in a different file

SSH Keys have been helping developers and system administrators quickly manage their servers without having to remember pesky passwords.

I’d like to re-use my SSH key as I have multiple machines that I’d like to easily access my resources with. Normally, I would store my personal priv/pub SSH Keys on Dropbox (with encryption of course) and then copy it over to my new machine.

But because I also keep different sets of keys around, I often found myself getting confused if this particular set of id_rsa/id_rsa.pub keys is the right one I’m looking for.

Wouldn’t it be great to be able to rename your identity keys to a filename that is more readable?

There’s a way!

  1. Rename your id_rsa/id_rsa.pub set to a name more readable.
$ mv ~/.ssh/id_rsa ~/.ssh/david_rsa
$ mv ~/.ssh/id_rsa.pub ~/.ssh/david_rsa.pub
  1. Modify (create) your ssh config file:
# ~/.ssh/config

IdentityFile ~/.ssh/david_rsa

Done.

Now copy your ~/.ssh/config file and keys to a easily sync-able location and you have your keys all in your fingertips.

Reference: Stackoverflow