pyca / pyca/cryptography

SSH comment parameter

Open
#15,484 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
7.8k
Forks
1.8k
Avg merge
7h 48m
Merged PRs (30d)
157

Description

Currently there is no opportunity for SSH format to add a comment like for the "corresponding" openSSH command:
ssh-keygen -t ed25519 -C "user@example.com" -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 "user@example.com" 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?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing the OpenSSH serialization path used by private_bytes with PrivateFormat.OpenSSH and inspect the related tests. Determine how an SSH comment can be represented in the private-key format, then verify that the proposed parameter embeds the requested comment while preserving encrypted key serialization.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
security
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
50/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.