[Twisted-Python] Need help with SSHUserAuthClient keyfile and passphrase

Stephen McRoberts steveo at mcroberts.org
Wed Jul 12 10:09:00 MDT 2017


In case some other lost person stumbles upon this question...
It's a lot of wizardry to me but here's how I got it to work.

    1. Generate a public key from private key with:
        ssh-keygen -f ~/.ssh/myserver.com-rsa -y -P old_passphrase -N new_passphrase > ~/.ssh/myserver.com-rsa.pub
    2. Put the public key in authorized_keys
        cat ~/.ssh/myserver.com-rsa.pub  >> ~/.ssh/authorized_keys

Now when getPublicKey is called, it calls getPrivateKey and all is well. You can retrieve the passphrase however you want but I made an SSHAuthOptions class to hold the keyfile and passphrase. Look at https://github.com/twisted/twisted/blob/twisted-17.5.0/src/twisted/conch/client/default.py and copy relevant parts from getPrivateKey and substitute your passphrase.

Take this for what you paid for it. I don't know much abut SSH2 and don't have the interest to learn so my methods may be called into question.



More information about the Twisted-Python mailing list