在 ezPyCrypto 中读取 Putty 生成的私钥
我使用 Putty Key Generator 创建了一个名为 Putty-Private.ppk
的私钥。我可以将此私钥与 Pageant 和 Putty 一起使用来连接到我的托管提供商的服务器。
现在,我想使用基于 xmlrpc 的远程 API 连接到服务器。为此,我安装了 ezPyCrypto,许多人建议它作为易于使用的 python 加密库。为了测试加密,我编写了以下代码:
mypass = "xxx"
fd = open("Putty-Private.ppk")
pubprivkey = fd.read()
fd.close()
k = ezPyCrypto.key(pubprivkey, passphrase = mypass)
dec = k.decString(enc)
但是系统在 ezPyCrypto.key(...)
调用中给出以下错误:
CryptoKeyError: Attempted to import invalid key, or passphrase is bad
我确信密码是正确的。所以,我想我不能在 ezPyCrypto 中使用 Putty 的私钥生成器。是这样吗?出现这个错误的原因是什么?
I used Putty Key Generator to create a private key, called Putty-Private.ppk
. I can use this private key with Pageant and Putty to connect to the servers of my hosting provider.
Now, I want to connect to the server with xmlrpc based remote API. To do this I installed ezPyCrypto which is advised by many as an easy to use python encryption library. To test the encryption I wrote the following code:
mypass = "xxx"
fd = open("Putty-Private.ppk")
pubprivkey = fd.read()
fd.close()
k = ezPyCrypto.key(pubprivkey, passphrase = mypass)
dec = k.decString(enc)
But the system gives the following error in ezPyCrypto.key(...)
invocation:
CryptoKeyError: Attempted to import invalid key, or passphrase is bad
I am sure that passphrase is correct. So, I guess I cannot use the private key generator by Putty in ezPyCrypto. Is that right? What is the explanation for the reason of this error?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
.ppk 扩展名让我猜测私钥来自 puttygen 中的“保存私钥”。除了 PuTTY 本身之外,几乎任何东西都不支持这种文件格式。我找不到 ezPyCrypto 期望的私钥格式,但您可能会更好地使用 puttygen 中的“转换 -> 导出 OpenSSH 密钥”创建的私钥文件。
The .ppk extension makes me guess the private key comes from "Save private key" in puttygen. This file format is not supported by pretty much anything except PuTTY itself. I can't find what private key format ezPyCrypto expects, but you might have better luck with a private key file made from "Conversions -> Export OpenSSH key" in puttygen.