Skip to main content

remove_known_hosts_entry

Function remove_known_hosts_entry 

Source
pub fn remove_known_hosts_entry(
    host: &str,
    port: u16,
    known_hosts: &Path,
) -> Result<()>
Expand description

Remove known_hosts entries matching host:port.

Reads the file line by line, drops entries whose host-pattern field matches, and writes the result back atomically (temp file + rename). Comments, blank lines, and hashed (|1|…) entries are preserved.

Returns Ok(()) when the file does not exist (nothing to remove).