You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I actually saw this independently the other day when digging into an unrelated key issue - I had need to run basic key generation and reached for Ed25519 out of "this is the current 'good key type' to use in a vacuum". And yup. It's missing this! Good to know Cryptography added it a while back.
For anyone that needs to just do it, the following code snippet works for ed25519 key generation using cryptography and then using io.StringIO as an interface to get the generated key into paramiko. From there, you're off to the races.
Could the cryptography .generate() just be wrapped/used directly using some of the code I wrote there? Unless I'm totally mistaken, this issue could be solved with a few lines of code and a few unit tests, no?
I can definitely write the code and PR to close this issue, I just want to make sure I'm on the right path before committing.
BTW: there's no bits or curve selection needed for generating ed25519. The method would just be .generate() and boom, it's done.
I've been running the just do it code in production for 6 months with no issues. I looked even more closely at the dir() of the cryptography private key object and the paramiko key object. Basically c_pkey._raw_private_bytes() results in the private key raw bytes from the cryptography key. That data is exactly what needs to go in Ed25519Key._signing_key. There is literally nothing else. All the other steps are to use existing paramiko code. If the Ed25519Key class just had a raw_key parameter and didn't have the exeption, there wouldn't be much else to do. You don't even need to wait for a generate() method to pass policy decisions.
Incidentally, I was looking for a python package to generate ed25519 keys and was going to choose paramiko (mostly as I'd already heard the name from Ansible, Boto, Fabric, etc.). I'll go ahead with @utkonoscode for the moment and look forward to turning that into a pure paramiko implementation at some stage in the future ✅
Thanks for the hard work everyone - much appreciated! 👍
@dd-ssc -- bitprophet has been working extensively on a new architecture for #387 and #23, but I believe that's more for authentication workflows rather than key generation.
Check out the 3.2 CHANGELOG to see the (experimental) additions in that release. I know he's planning staged addition and rollout of these features through multiple releases, so auth is going to be the focus for some time yet.
Once that's solidified, then AFAIK he's going to turn to other fixes and features.
I've been running the just do it code in production for 6 months with no issues. I looked even more closely at the dir() of the cryptography private key object and the paramiko key object. Basically c_pkey._raw_private_bytes() results in the private key raw bytes from the cryptography key. That data is exactly what needs to go in Ed25519Key._signing_key. There is literally nothing else. All the other steps are to use existing paramiko code. If the Ed25519Key class just had a raw_key parameter and didn't have the exeption, there wouldn't be much else to do. You don't even need to wait for a generate() method to pass policy decisions.
Activity
max-wittig commentedon May 7, 2018
Any updates on this?
dopaminereceptionist commentedon May 9, 2018
Also interested in this. Should be reasonably straight forward.
johnnybubonic commentedon Aug 10, 2018
for reference:
here's a python 2 implementation: https://github.com/pts/py_ssh_keygen_ed25519
here's an implementation in Go (do NOT use this one as the only reference since it purposely generates deterministic keys; just including for your reference): https://github.com/joonakannisto/determin-ed
here's an implementation in Haskell (do NOT use this one's examples either; another deterministic-on-purpose implementation): https://github.com/mithrandi/ssh-key-generator
here's the overview of the new "openssh-key-v1" format that ssh_ed25519 always uses: https://github.com/openssh/openssh-portable/blob/master/PROTOCOL.key
(which you should add support for for RSA and ECDSA keys as well, since openssh has announced that'll be the default at some time in the future anyways)
further information on the new key format:
https://github.com/openssh/openssh-portable/blob/master/sshkey.c
https://peterlyons.com/problog/2017/12/openssh-ed25519-private-key-file-format
hope that helps.
dopaminereceptionist commentedon Oct 4, 2018
Thank you, that's very helpful.
johnnybubonic commentedon Feb 27, 2019
@bitprophet looks like this should be much more simplified since the cryptography module has now implemented ed25519.
paprickar commentedon Mar 2, 2022
@bitprophet do you have a gut feeling when this can be implemented?
bitprophet commentedon Mar 4, 2022
I actually saw this independently the other day when digging into an unrelated key issue - I had need to run basic key generation and reached for Ed25519 out of "this is the current 'good key type' to use in a vacuum". And yup. It's missing this! Good to know Cryptography added it a while back.
I see I added it to the feature milestone some time ago. I have no firm ETA for it but see https://bitprophet.org/projects/#roadmap - this one absolutely qualifies for my next set of feature-adds. Expect I'd hope to get to this after the Python 2 removal release (again per that roadmap).
utkonos commentedon Jun 20, 2022
For anyone that needs to just do it, the following code snippet works for ed25519 key generation using
cryptographyand then usingio.StringIOas an interface to get the generated key intoparamiko. From there, you're off to the races.utkonos commentedon Jun 20, 2022
Could the cryptography
.generate()just be wrapped/used directly using some of the code I wrote there? Unless I'm totally mistaken, this issue could be solved with a few lines of code and a few unit tests, no?I can definitely write the code and PR to close this issue, I just want to make sure I'm on the right path before committing.
BTW: there's no
bitsorcurveselection needed for generatinged25519. The method would just be.generate()and boom, it's done.utkonos commentedon Dec 27, 2022
I've been running the just do it code in production for 6 months with no issues. I looked even more closely at the
dir()of thecryptographyprivate key object and theparamikokey object. Basicallyc_pkey._raw_private_bytes()results in the private key raw bytes from thecryptographykey. That data is exactly what needs to go inEd25519Key._signing_key. There is literally nothing else. All the other steps are to use existingparamikocode. If theEd25519Keyclass just had araw_keyparameter and didn't have the exeption, there wouldn't be much else to do. You don't even need to wait for agenerate()method to pass policy decisions.paramiko/paramiko/ed25519key.py
Lines 65 to 66 in bbb8d57
Here is the

cryptographydata:Here is the

paramikodata using the code I wrote to Rube Goldberg it into the format the currentparamikocode can use.dd-ssc commentedon Jun 8, 2023
Any updates on this ?
Incidentally, I was looking for a python package to generate
ed25519keys and was going to chooseparamiko(mostly as I'd already heard the name from Ansible, Boto, Fabric, etc.). I'll go ahead with @utkonos code for the moment and look forward to turning that into a pure paramiko implementation at some stage in the future ✅Thanks for the hard work everyone - much appreciated! 👍
bskinn commentedon Jun 8, 2023
@dd-ssc -- bitprophet has been working extensively on a new architecture for #387 and #23, but I believe that's more for authentication workflows rather than key generation.
Check out the 3.2 CHANGELOG to see the (experimental) additions in that release. I know he's planning staged addition and rollout of these features through multiple releases, so auth is going to be the focus for some time yet.
Once that's solidified, then AFAIK he's going to turn to other fixes and features.
evan0greenup commentedon Mar 25, 2024
When using this method to generate
ed25519key, the key file is not passphrase protected.utkonos commentedon Mar 25, 2024
Yes, that's correct. If you have a suggestion for adding password protection, please go ahead.
On a side note: I think the probability of ed25519 key generation being supported by paramiko is zero, so please help where you are able to.