SSH comment parameter
Author: DoctorD90Created Aug 19, 2026Updated Aug 20, 2026
Currently there is no opportunity for SSH format to add a comment like for the "corresponding" openSSH command:
ssh-keygen -t ed25519 -C "[email protected]" -N "MySecretPassword" -f id_ed25519_key
In the current version an SSH key is generated like that:
key_bytes = key.private_bytes(
encoding=serialization.Encoding.PEM,
format=serialization.PrivateFormat.OpenSSH,
encryption_algorithm=serialization.BestAvailableEncryption("MySecretPassword".encode('utf-8')),
)but there is no ssh_comment parameter to be used to add the "[email protected]" to the private key.
Ok, it is there a work around for the PUBLIC key appending the comment, but with SSH format is possible to "embed" the comment inside the private key directly.
Would be possible to implement that feature in the library?
Source: pyca/cryptography