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?
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.