Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I would like to be able to use

ssh user@host

without the -i identity_rsa_or_else_private_key_file . Is there a place somewhere in ssh configs where I can point where are the private keys located so that the ssh will automatically choose one for the connection (so that I don't have to type -i key_file)?

share|improve this question
add comment

1 Answer

up vote 6 down vote accepted

I suggest reading the ssh_config man page. If you want to have a specific identity per-host, and another for all other hosts, do something like this in your ~/.ssh/config:

Host hostname.example.com
    IdentityFile ~/.ssh/identity_rsa_or_else_private_key_file

Host *
    IdentityFile ~/.ssh/another_identity_file

By default, it uses ~/.ssh/id_rsa for the IdentityFile for RSA identities and ~/.ssh/id_dsa for DSA identities, so if you don't want to change your ~/.ssh/config, you can just rename the file to that name.

share|improve this answer
    
Thanks a lot !!! It worked like a charm. –  Patryk Dec 19 '12 at 16:08
2  
Please note that IdentityFile only adds keys to what your key agent already offers to the SSH clients. If you have your key agent already N number of keys available, it will try to authenticate with N+1 keys, with the one you specified as the last one. Some SSH servers will have blocked you already by then. Check that with ssh -vvv and you might want to disable your SSH key agent by enabling IdentitiesOnly. –  gertvdijk Dec 19 '12 at 16:17
add comment

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.