pub fn write_secret_file_atomic(path: &Path, data: &[u8]) -> SshCliResult<()>Expand description
Writes secret bytes to path atomically, never exposing them at a wider mode.
A2: writing with std::fs::write creates the file at 0644 under the default
umask and only narrows it afterwards, leaving a window where a private key is
world-readable. tempfile::NamedTempFile creates at 0600 via O_EXCL, so the
content is never observable by other users, and the rename is atomic.
ยงErrors
Directory creation, temp-file creation, write, fsync, mode change or rename failure.