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 need to convert SSH2-formatted public keys to the SSH format.
So far (by poking around) I managed to find out there's this public_bytes() method on the RSA type of keys (the ones which are put in the SSHKey.rsa attribute).
But I also need to support other key types (like ECDSA).
How should I serialize those into the SSH format?
The use case: original public keys are 'stored' in the 'plain text' (PEM? not much familiar w/the lingo) format containing those ---- BEGIN SSH2 PUBLIC KEY ---- markers. This format needs to be converted to the SSH (OpenSSH?) format like ssh-rsa <base64-encoded data>.
I tried to looks through the source code but am not sure about what to do w/apparently 'binary' string for a ECDSA public keys.
My current code looks like:
parsedKey=SSHKey(publicKey)
parsedKey.parse()
ifparsedKey.rsa:
return (
parsedKey.rsa.public_bytes(
serialization.Encoding.OpenSSH,
serialization.PublicFormat.OpenSSH)).decode()
else:
# this is wrong data format. need help herereturnparsedKey.ecdsa.to_string()
Any help?
The text was updated successfully, but these errors were encountered:
Team,
I need to convert SSH2-formatted public keys to the SSH format.
So far (by poking around) I managed to find out there's this
public_bytes()
method on the RSA type of keys (the ones which are put in theSSHKey.rsa
attribute).But I also need to support other key types (like ECDSA).
How should I serialize those into the SSH format?
The use case: original public keys are 'stored' in the 'plain text' (PEM? not much familiar w/the lingo) format containing those
---- BEGIN SSH2 PUBLIC KEY ----
markers. This format needs to be converted to the SSH (OpenSSH?) format likessh-rsa <base64-encoded data>
.I tried to looks through the source code but am not sure about what to do w/apparently 'binary' string for a ECDSA public keys.
My current code looks like:
Any help?
The text was updated successfully, but these errors were encountered: