基于docstring,此方法接受以下参数:
Docstring: Session.userauth_publickey_fromfile(self, username, privatekey, passphrase='', publickey=None) Authenticate with public key from file.
但是official project description有这样一个例子:
session.userauth_publickey_fromfile( username, 'my_pkey.pub', 'my_pkey', '')
所以在这个例子中,第二个参数是一个公钥,但是docstring说它必须是一个私钥。在
在docstring中还有2个位置参数,但在给定的示例中有4个。在
那么正确的参数组合是什么呢?在
提前谢谢。在
另外,还不清楚哪种格式应该是privatekey和publickey。它应该像文件或字节的路径吗?如果它是以字节为单位,那么为什么整个函数名为“_fromfile”?非常混乱。在
终于找到了正确的参数组合:
在我的情况下没有密码短语,所以没有提供。 不知道作者为什么这样实现这个函数。“privatekey”是一个强制文件,可以随时从中生成公钥。但它们还有“publickey=”的附加关键字参数。在
从Documentation开始,只有
publickey
,types
解释了。出于安全原因,私钥永远不应该存储在python脚本中。 你必须从受访问限制的文件存储中读取。在
您是对的,参数应该解释为
userauth_publickey(...)
。在相关问题 更多 >
编程相关推荐