SCAN_TIMEOUT_SECconstno test imports itconst SCAN_TIMEOUT_SEC: 8The seconds ssh-keyscan waits for a host.
The host keys and the key tools of OpenSSH as typed helpers (commons headless 0007-ssh-coverage FR-005): the argument vectors of ssh-keyscan -T 8 [-p], ssh-keygen -lf -, -y, -R and -Y find-principals, and generation, and the parsing of what they write (the keys a host showed, deduplicated and in the order that makes ed25519 first, a fingerprint with its size, its comment and its type), and the text of a known-hosts file for the keys pinned for a host. They only make arguments and read text: nothing here runs a program, and nothing records a key as trusted: that is the verb of first contact, which a person confirms.
import { parseFingerprint, parseScan } from "./hostkeys.ts";
parseFingerprint("256 SHA256:abc alpha (ED25519)\n"); // { bits: 256, fingerprint: "SHA256:abc", comment: "alpha", type: "ED25519" }
parseScan("alpha ssh-ed25519 AAAA\n")[0]?.type; // "ssh-ed25519"SCAN_TIMEOUT_SECconstno test imports itconst SCAN_TIMEOUT_SEC: 8The seconds ssh-keyscan waits for a host.
HostKeytypeno test imports ittype HostKey = { readonly host: string; readonly type: string; readonly key: string; readonly line: string };One key a host showed, as a line of a known-hosts file.
scanArgvfunctionfunction scanArgv(t: Target): readonly string[]The arguments that fetch the keys a host shows: ssh-keyscan -T 8 [-p port] -- <address>.
parseScanfunctionfunction parseScan(text: string): readonly HostKey[]The keys in what ssh-keyscan wrote: comment lines and what is not a key are left out, the same key once, and ed25519 first (then the other types in a fixed order, the rest in the order shown).
FINGERPRINT_ARGVconstconst FINGERPRINT_ARGV: readonly string[]The arguments that make the fingerprint of the key or keys on the standard input: ssh-keygen -l -f -.
Fingerprinttypeno test imports ittype Fingerprint = { readonly bits: number; readonly fingerprint: string; readonly comment: string; readonly type: string };A fingerprint as ssh-keygen -l writes it.
parseFingerprintfunctionfunction parseFingerprint(text: string): Fingerprint | undefinedThe fingerprint in the output of ssh-keygen -l (256 SHA256:... comment (ED25519)), or undefined where there is none.
publicKeyArgvfunctionfunction publicKeyArgv(privateKeyFile: string): readonly string[]The arguments that make the public key of a private key file: ssh-keygen -y -f <file>; the file is named, never read here.
knownHostNamefunctionfunction knownHostName(t: Target): stringThe host as a known-hosts file names it: the address, or [address]:port for a port other than 22.
removeHostArgvfunctionfunction removeHostArgv(t: Target, knownHostsFile: string): readonly string[]The arguments that remove a host from a known-hosts file: ssh-keygen -R <host> -f <file>.
findPrincipalsArgvfunctionfunction findPrincipalsArgv(allowedSigners: string, signatureFile: string): readonly string[]The arguments that find who signed: ssh-keygen -Y find-principals -s <signature> -f <allowed signers>.
KeygenInputtypeno test imports ittype KeygenInput = { readonly type: "ed25519" | "rsa"; readonly comment: string; readonly file: string; readonly bits?: number };What a key is made with.
keygenArgvfunctionfunction keygenArgv(i: KeygenInput): readonly string[]The arguments that make a key with no passphrase: ssh-keygen -q -t <type> [-b bits] -N "" -C <comment> -f <file>. A key a person protects with a passphrase is made by the person, interactively.
pinnedKnownHostsfunctionfunction pinnedKnownHosts(t: Target, keys: readonly HostKey[]): stringThe text of a known-hosts file for the keys pinned for a target: one line for each, the host as the file names it ([address]:port where the port is not 22). Used as the file of the family pinned.