/** * Hinweise zum sshd-Befund eines Hosts (#010). Nur Anzeige: sshkv aendert sshd_config * nie ohne ausdrueckliche Bestaetigung (Vorgabe „Bootstrap“). */ export type SshdHinweis = { readonly stufe: "warnung" | "gefahr" | "info"; readonly text: string }; export function sshdHinweise(befund: Record | null | undefined): SshdHinweis[] { if (!befund) return []; const wert = (name: string) => typeof befund[name] === "string" ? (befund[name] as string).toLowerCase() : ""; const hinweise: SshdHinweis[] = []; if (wert("permitRootLogin") === "yes") { hinweise.push({ stufe: "warnung", text: "root darf sich per Passwort anmelden. Empfohlen: PermitRootLogin prohibit-password.", }); } if (wert("passwordAuthentication") === "yes") { hinweise.push({ stufe: "info", text: "Passwort-Anmeldung ist für alle Benutzer aktiv." }); } if (wert("pubkeyAuthentication") === "no") { hinweise.push({ stufe: "gefahr", text: "Anmeldung per Schlüssel ist abgeschaltet – sshkv kann so nicht arbeiten.", }); } const dateien = wert("authorizedKeysFile"); if ( dateien && !dateien.split(/\s+/).some((d) => d === ".ssh/authorized_keys" || d === "%h/.ssh/authorized_keys") ) { hinweise.push({ stufe: "gefahr", text: `sshd liest Schlüssel aus „${befund["authorizedKeysFile"] as string}“, sshkv schreibt nach ~/.ssh/authorized_keys.`, }); } return hinweise; }