Skip to main content

generate_key_pair

Function generate_key_pair 

Source
pub async fn generate_key_pair(
    host_name: &str,
    key_type: KeyType,
) -> Result<(PathBuf, PathBuf)>
Expand description

Generates an Ed25519 SSH key pair and writes it to disk.

Returns the paths to the private and public key files.

§Errors

Returns an error if key generation or file I/O fails.

§Safety

  • Private key is written with mode 0600.
  • .ssh directory is created with mode 0700 if it doesn’t exist.