何时以及为何使用 load_host_keys 和 load_system_host_keys? [英] When and why to use load_host_keys and load_system_host_keys?

查看:53
本文介绍了何时以及为何使用 load_host_keys 和 load_system_host_keys?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我第一次使用其私钥文件连接到主机.在连接到主机之前是否需要调用 load_host_keys 函数?或者我可以跳过它吗?我有用于丢失主机密钥的 autoAddPolicy,但是 python 如何知道主机密钥文件的位置?

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?

因此我的问题是,何时使用 load_host_key 函数?

Hence my question, when to use the function load_host_key?

推荐答案

从本地主机密钥文件加载主机密钥.使用此方法读取的主机密钥将在通过 load_system_host_keys 加载密钥后进行检查,但将由 save_host_keys 保存回来(因此它们可以被修改).丢失的主机密钥策略 AutoAddPolicy 在连接到以前未知的服务器时向该集合添加密钥并保存它们.

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.

以 openssh 使用的格式读取已知 SSH 主机密钥的文件.不幸的是,这种类型的文件在 Windows 上不存在,但在 posix 上,它通常会存储在 os.path.expanduser("~/.ssh/known_hosts") 中.

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").

这篇关于何时以及为何使用 load_host_keys 和 load_system_host_keys?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆