Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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

1 Answer 1

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 *.example.com
    IdentityFile ~/.ssh/identity-example.com

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: "mykeyname-myhost.com" ? –  MEM Mar 28 '11 at 10:55
    
That's just the file name. So to use that configuration, I'd need to have ~/.ssh/identity-example.com and ~/.ssh/identity-example.com.pub files. The file names don't really matter. –  James Henstridge Mar 29 '11 at 2:01

Your Answer

 
discard

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.