I am connecting to a host for the first time using its private key file. Do I need to call load_host_keys function before connecting to the host? Or Can I just skip it? I have the autoAddPolicy for missing host key but how can python know the location of the host key file?
Hence my question, when to use the function load_host_key?
Load host keys from a local host-key file. Host keys read with this method will be checked after keys loaded via load_system_host_keys, but will be saved back by save_host_keys (so they can be modified). The missing host key policy AutoAddPolicy adds keys to this set and saves them, when connecting to a previously-unknown server.
This method can be called multiple times. Each new set of host keys will be merged with the existing set (new replacing old if there are conflicts). When automatically saving, the last hostname is used.
Read a file of known SSH host keys, in the format used by openssh. This type of file unfortunately doesn't exist on Windows, but on posix, it will usually be stored in os.path.expanduser("~/.ssh/known_hosts").
When and why to use load_host_keys and load_system_host_keys?