Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

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

id_rsa is, normally a default identity. However, I've created a new key and I would like to add that key as a default identify instead.

How can we do that?

Thanks a lot in advance.

share|improve this question
up vote 5 down vote accepted

In your ~/.ssh/config file (create it if it doesn't already exist), you can specify which key to use with the IdentityFile directive:

IdentityFile ~/path/to/your/key

You can use this directive inside a "Host" section if you only want to use that key for a particular host. For example:

Host *
    IdentityFile ~/.ssh/

If you run "ssh -v hostname", the debug information should confirm that it is using the key you specified.

share|improve this answer
Thank you very much. – MEM Mar 28 '11 at 10:23
About your last example, when you have identity-example you are refering to the key name or, some sort of syntax using specificly the -myhost, like: "" ? – MEM Mar 28 '11 at 10:55
That's just the file name. So to use that configuration, I'd need to have ~/.ssh/ and ~/.ssh/ files. The file names don't really matter. – James Henstridge Mar 29 '11 at 2:01

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.