Pyinfra: OSError: No such private key file when using OPENSSH PRIVATE KEY

Created on 12 Mar 2021  路  6Comments  路  Source: Fizzadar/pyinfra

So this took a few hours for me to figure out, and wanted to post the solution online.

Basically paramiko doesn't support openssh private key format before version 2.7.

Solution A: Ensure paramiko is at least version 2.7
pip3 install paramiko --upgrade

Solution B: Convert your private key to PEM format (usable by paramiko <=2.6)
ssh-keygen -p -m PEM -f ./your_private_key

You're welcome.

Bug

All 6 comments

Would be very cool to simply bump the minimum version of paramiko to 2.7 in pyinfra but that's up to @Fizzadar

I think bumping the required version is the ideal solution - however it's technically a breaking change 馃槵! I'm going to leave this issue here while I figure out how to handle this, perhaps a warning until pyinfra 2.x is the best approach (ie warn if we fail to load a key explaining to upgrade paramiko).

Implemented the warning in https://github.com/Fizzadar/pyinfra/commit/6347e352a3b6ed0dc038e50c9ded52af75ae8b40 (and fixed the general not found vs. invalid key error message), released in 1.3.9 just now!

Great. Thanks @Fizzadar

It has occurred to me that bumping the minimum paramiko version from 2.2 to 2.7 isn't a breaking change, not sure what I was thinking originally; this semver issue explains it well, so will be bumping this in 1.4!

Nice one @Fizzadar !

Was this page helpful?
0 / 5 - 0 ratings