Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ssh use known_hosts other than $HOME/.ssh/known_hosts [closed]

Tags:

ssh

ubuntu

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.

like image 204
user1085687 Avatar asked May 26 '12 11:05

user1085687


1 Answers

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.

like image 96
Raymond Tau Avatar answered Oct 01 '22 20:10

Raymond Tau