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

UbuntuSsh

Ubuntu Problem Overview


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.

Ubuntu Solutions


Solution 1 - Ubuntu

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.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
Questionuser1085687View Question on Stackoverflow
Solution 1 - UbuntuRaymond TauView Answer on Stackoverflow