Expand description
Generating an SSH key pair, in process.
Why not shell out to ssh-keygen. It is not reliably installed
(Windows ships the OpenSSH client as an optional feature that managed
images often have off, and the binary on PATH may be Git for
Windows’, WSL’s or none) and it is interactive by default. ssh-key
produces the same OpenSSH-format files with no process and no prompt.
Ed25519 by default. Short, fast, and accepted by both GitHub and
GitLab. ssh.key_type can ask for RSA (4096 bits) or ECDSA (NIST
P-256) instead, see KeyType.
No passphrase. A generated key is written unencrypted, as
ssh-keygen -N "" would, because the point is a key an agent-less
git fetch can use unattended. The file permissions below are what
protects it; the docstring on generate_and_write says so.
Structs§
- Generated
Key - A freshly generated pair. The private half is held only long enough to be written; nothing in this crate sends it anywhere.
Enums§
- KeyType
- The kind of key to generate (
ssh.key_type).
Functions§
- default_
key_ path - The default key path,
~/.ssh/id_ed25519, which is where ssh looks without being told. - default_
key_ title - A default title for an uploaded key: the machine’s name, so a user with keys from three machines can tell them apart on the host’s settings page.
- fingerprint_
of SHA256:...of an OpenSSH public-key line, orNonewhen it is not one.- generate_
and_ write - Generates an Ed25519 pair (see
generate_typed_and_writefor the others) and writes it topathandpath.pub. - generate_
typed_ and_ write generate_and_writefor a chosenKeyType.- profile_
key_ path - The private-key path a profile’s generated key gets inside
ssh_dir:gitpoulpi_<profile id>_ed25519. Per profile so two accounts on one host never share (or overwrite) a key. - profile_
key_ title - The title a profile’s key gets when the user does not type one:
GitPoulpi <host> <YYYY-MM-DD>. - same_
public_ key - Whether two public-key lines are the same key (the comment, which hosts rewrite, is ignored).
- ssh_
command_ for_ key - The
core.sshCommandvalue that pins one private key for a repository (ADR-0008):ssh -i "<key>" -o IdentitiesOnly=yes. Backslashes become forward slashes, which git’sshaccepts on Windows too. - ssh_dir
~/.ssh, where ssh looks for keys.