ssh默认会在?/ .ssh文件夹中查找其键。 我想强迫它始终在另一个位置查看。
我正在使用的解决方法是将密钥从非标准位置添加到代理中:
1 2
| ssh-agent
ssh-add /path/to/where/keys/really/are/id_rsa |
(在Linux和Windows上的MingW32 shell上)
如果您只是想为身份文件指向其他位置,则可以使用以下条目来修改?/ .ssh / config文件:
1
| IdentityFile ~/.foo/identity |
man ssh_config查找其他配置选项。
man ssh给我这个选项可能会有用。
-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).
因此,您可以在bash配置中使用以下方式创建别名:
alias ssh="ssh -i /path/to/private_key"
我没有查看ssh配置文件,但是像-i选项一样,也可以使用别名
-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.