pub fn write_keypair(
key: &PrivateKey,
path: &Path,
passphrase: Option<&Zeroizing<String>>,
) -> Result<(), GitwayError>Expand description
Writes a keypair to disk.
Two files are created:
| Path | Contents | Unix mode |
|---|---|---|
path | OpenSSH private key (optionally encrypted) | 0600 |
path.pub | OpenSSH public key (authorized_keys line) | 0644 |
If passphrase is Some, the private key is encrypted before writing.
Passing Some(empty_string) is rejected — use None for an unencrypted
key.
§Errors
Returns GitwayError on I/O failure, encryption failure, or when the
output parent directory does not exist.