Skip to main content

write_keypair

Function write_keypair 

Source
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:

PathContentsUnix mode
pathOpenSSH private key (optionally encrypted)0600
path.pubOpenSSH 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.