tags:

views:

1231

answers:

3

ssh will look for its keys by default in the ~/.ssh folder. I want to force it to always look in another location.

The workaround I'm using is to add the keys from the non-standard location to the agent:

ssh-agent
ssh-add /path/to/where/keys/really/are/id_rsa

(on Linux and MingW32 shell on Windows)

+2  A: 

You could throw in symlinks?

J.D. Fitz.Gerald
A: 

man ssh gives me this options would could be useful.

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

So you could create an alias in your bash config with something like

alias ssh="ssh -i /path/to/private_key"

I haven't looked into a ssh configuration file, but like the -i option this too could be aliased

-F configfile Specifies an alternative per-user configuration file. If a con- figuration file is given on the command line, the system-wide configuration file (/etc/ssh/ssh_config) will be ignored. The default for the per-user configuration file is ~/.ssh/config.

roo
+2  A: 

If you are only looking to point to a different location for you identity file, the you can modify your ~/.ssh/config file with the following entry:

IdentityFile ~/.foo/identity

man ssh_config to find other config options.

Drew Frezell
perfect, thanks Drew.
tardate
Note also that you can list this parameter multiple times for multiple keys. However, listing too many keys (typically >4) can cause auth to fail before prompting for a password on systems where your key isn't valid. ssh-agent, or keychain (http://www.gentoo.org/proj/en/keychain/) are helpful here.
jmanning2k