I want to to make it so that when a file looks for a ssh key in /Users/skline/.ssh/id_rsa.pub it automatically also looks into the directory /var/root/.ssh/id_rsa.pub (where my ssh is actually located.) How do I do this on OSX? I am new to the terminal, so thanks :)

1 Answer 1


If its anything like the SSH I use, then you should be able to use the '-i' option.

e.g. ssh host -i /var/root/.ssh/id_rsa

From the man page:

 -i identity_file
     Selects a file from which the identity (private key) for RSA or
     DSA authentication is read.  The default is ~/.ssh/identity for
     protocol version 1, and ~/.ssh/id_rsa and ~/.ssh/id_dsa for pro-
     tocol version 2.  Identity files may also be specified on a per-
     host basis in the configuration file.  It is possible to have
     multiple -i options (and multiple identities specified in config-
     uration files).

Or for a permanent solution, add the following option (with path) to your ~/.ssh/config

 IdentityFile /var/root/.ssh/id_rsa

And again, appropriate man page entry:

         Specifies a file from which the user's DSA, ECDSA or DSA
         authentication identity 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.  Additionally, any
         identities represented by the authentication agent will be used
         for authentication.  ssh(1) will try to load certificate
         information from the filename obtained by appending -cert.pub to
         the path of a specified IdentityFile.

         The file name may use the tilde syntax to refer to a user's home
         directory or one of the following escape characters: `%d' (local
         user's home directory), `%u' (local user name), `%l' (local host
         name), `%h' (remote host name) or `%r' (remote user name).

         It is possible to have multiple identity files specified in
         configuration files; all these identities will be tried in
  • so should I simply add the line to my config file? I currently don't have a config file, so should I create it?
    – Spencer
    Feb 21, 2011 at 0:00
  • yep and yep :-) (smiley face there to reach character limit for comments)
    – Pricey
    Feb 21, 2011 at 0:09
  • I got an error when I used id_rsa.pub instead of id_rsa. Not sure which is more correct, but just a note that is hopefully useful to someone. Jun 1, 2011 at 18:04
  • Bah yes, I think I should remove those .pub's sorry! Hopefully the documentation I linked/quoted made things clear.
    – Pricey
    Jun 1, 2011 at 19:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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