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)?

1 Answer 1


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.

  • 3
    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
    Commented Dec 19, 2012 at 16:17

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .