Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have recently began making use of RSA Key pairs to login to various servers I manage and wanted to get some insight on best practice as I recently ran into some issues.

Is it best practice to keep only one RSA key on your local and register the same key with each server you are going to login to? I recently tried adding an additional key for a new server I need to access and it was not working correctly.

Thank you in advance.

share|improve this question

migrated from Nov 1 '11 at 23:54

This question came from our site for professional and enthusiast programmers.

Make sure you chmod 700 ~/.ssh and chmod 600 ~/.ssh/authorized_keys on the server side. ssh wont allow key logins if the .ssh and auth_keys files are overly permissive. – chown Nov 1 '11 at 20:01
up vote 1 down vote accepted

I'm not sure if it's "standard" or not, but if you're going to use more than one key you will need to specify which you want to use on the command line or specified per host in your ~/.ssh/config file. From the OpenSSH man page:

     -i identity_file
         Selects a file from which the identity (private key) for public key authentication is read.  The default is
         ~/.ssh/identity for protocol version 1, and ~/.ssh/id_dsa, ~/.ssh/id_ecdsa and ~/.ssh/id_rsa for protocol
         version 2.  Identity files may also be specified on a per-host basis in the configuration file.  It is pos‐
         sible to have multiple -i options (and multiple identities specified in configuration files).  ssh will
         also try to load certificate information from the filename obtained by appending to identity

Example config entry:

IdentityFile ~/tmp/example_rsa
share|improve this answer
Thanks for the insight, this is definitely helpful for adding keys. My main reasoning was to get some insight on best practice and why someone would use one key instead of many. +1 – jnolte Nov 3 '11 at 4:24
In practice most people use one key just because it's easier. I've had to use multiple keys before because the admin of a remote site generated my keypair for me and sent me my private key (they did this rather than issue passwords). But that seems to be non-standard. – Andy M. Nov 3 '11 at 13:47

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.