ssh use known_hosts other than $HOME/.ssh/known_ho

2019-03-08 19:00发布

问题:

Is it possible to run SSH using another known_hosts file than the standard $HOME/.ssh/known_hosts for the user?

Note, that SSH uses $HOME original for the user. If you try to change it, e.g.

export HOME=some_other_location

it does not affect the location SSH uses to look for known_hosts.

回答1:

You may specify an alternative known_hosts file in $HOME/.ssh/config or /etc/ssh/ssh_config, the parameter UserKnownHostsFile.

Alternatively, if you prefer to use alternative known_hosts file for a specific SSH invocation, you may use the SSH command option -o UserKnownHostsFile=<alternative known_hosts file>, e.g. ssh -o UserKnownHostsFile=~/my_temporary_known_host ssh_host.



标签: ubuntu ssh