Auf der Hostseite: Host-Key abrufen, Fingerprint vergleichen und vertrauen oder ablehnen. Weicht ein Key vom vertrauten ab, erscheint eine deutliche Warnung, und Annehmen geht nur mit Haekchen und frischer Bestaetigung. Danach Bootstrap per Einmal-Passwort oder per Befehl und Verbindungspruefung, jeweils mit Fortschrittsanzeige. Der sshd-Befund empfiehlt prohibit-password, wenn root sich per Passwort anmelden darf - nur als Hinweis, geaendert wird nichts. E2E im gebauten Stand mit Worker gegen ein echtes sshd. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
40 lines
1.4 KiB
TypeScript
40 lines
1.4 KiB
TypeScript
/**
|
||
* 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<string, unknown> | 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;
|
||
}
|