ScannedKeytypetype ScannedKey = { readonly line: string; readonly fingerprint: string };What a host showed: each key's line as a known-hosts file holds it, and its fingerprint.
The first contact with a host (commons headless 0005-reach-and-targets FR-006; 0007-ssh-coverage FR-002): a host key that does not match is refused and never accepted for the person, and a host not yet known is learned only by a verb of its own that a person runs. scanHost fetches what the host shows (through ssh-keyscan and ssh-keygen -l) and gives the fingerprints; acceptHostKey writes the host to the repository's known hosts only where the person gave the fingerprint they checked and it is one of those the host showed. Nothing is accepted by a flag that says yes to everything; StrictHostKeyChecking=accept-new is not written anywhere.
import { acceptHostKey } from "./hostkey.ts";
// const r = await acceptHostKey(alpha, scan, "SHA256:...", (line) => appendToKnownHosts(line));ScannedKeytypetype ScannedKey = { readonly line: string; readonly fingerprint: string };What a host showed: each key's line as a known-hosts file holds it, and its fingerprint.
scanHostfunctionfunction scanHost(t: Target, run: RunLocal): Promise<Result<readonly ScannedKey[], string>>The fingerprints of the keys a host shows, through ssh-keygen -l (one call for each line, so that a line is never mistaken for another); ed25519 first.
acceptHostKeyfunctionfunction acceptHostKey(t: Target, scanned: readonly ScannedKey[], expected: string, append: (line: string) => void | Promise<void>): Promise<Result<readonly ScannedKey[], string>>Writes a host to the known hosts only if expected, the fingerprint a person checked by another way, is one that the host showed; append writes the line (the caller's: the repository's known-hosts file). A fingerprint that is not among them writes nothing, and says what the host showed.