Härtungs-Check und Schlüssel-Inventar

Härtungs-Check (F6 h, Palette für Ordner): nur lesend; sshd, sudo
NOPASSWD, Firewall, offene Ports, automatische Updates, UID 0, leere
Passwörter, TLS-Zertifikate, Zeitabgleich. Ampel mit Vorschlag, ändert
nichts.

Schlüssel-Inventar (F6 a, Palette für Ordner): authorized_keys aller
Benutzer, ein Eintrag je Schlüssel mit Hosts; d entfernt nach Bestätigung
je Host, mit Sicherungskopie; der eigene Anmeldeschlüssel bleibt.
Doku, Webseite und Kurzreferenz mitgezogen.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018i4GUj1JqSmBpmAhAgpD8W
This commit is contained in:
Claude committed 2026-11-14 08:13:02 +00:00
1 parent 680dfd7558
commit ed8a6ec2b7
31 files changed
+2053 -40

No files matched your search

+4 -1
View File
@@ -71,6 +71,8 @@ nicht als Beweis. Die Liste: Palette *Logwache: Meldungen* oder `w` im Log-Blick
- **Sicherheitscheck (OSV)** (`s` in F6, Palette *Sicherheitscheck*): liest über die offene Sitzung die installierten Pakete eines Linux-Servers, nur lesend (Debian/Ubuntu, RHEL/Rocky/Alma, SUSE, Alpine; mit `sudo -n` auch laufende Docker-/Podman-Container), und gleicht sie mit der öffentlichen [OSV](https://osv.dev)-Datenbank ab. Den Rechner verlassen nur Paketnamen und Versionen, nie Hostnamen oder Terminalinhalt. Das Ergebnis zeigt nur, was zählt: je Paket die höchste Bewertung, ob es eine reparierte Version gibt, ob die CVE auf der CISA-Liste aktiv ausgenutzter Lücken (KEV) steht und ob ein laufender Dienst mit offenem Port das Paket nutzt (`sshd :22`). Was die Distribution als geringfügig einstuft, wird gezählt, aber nicht gezeigt. ⏎ Details, `u` fügt den Update-Befehl für dieses Paket am Prompt ein (nicht ausgeführt), `k` lässt die KI das Risiko in Klartext erklären, `f` nur reparierbare, `x`/`X` nimmt einen Befund für den Host oder den ganzen Ordner hin (kommt zurück, sobald eine neue CVE dazukommt), `n` zeigt hingenommene, `c` kopiert als Markdown. In F6 steht eine Zeile *Sicherheit* mit dem letzten Ergebnis. Beim ersten Mal fragt sshTermy *online* (fragt die OSV-API, klein) oder *offline* (lädt die Datenbank je Distribution einmal am Tag, z. B. 80 MB für Debian; von deinen Paketen verlässt nichts den Rechner); Einstellungen › *Sicherheitscheck (OSV)* ändert das und setzt einen Firmen-Spiegel. Palette *Sicherheitscheck: alle Server im Ordner* prüft einen ganzen Ordner (4 gleichzeitig, eine Zeile pro Host); als Zeitplan (Art *Sicherheitscheck (OSV)*) läuft er z. B. wöchentlich und meldet sich nur, wenn etwas Neues hoch, kritisch oder KEV ist.
- **Firmware-Hinweise für Switches und Firewalls** (`s` in F6 am Netzwerkgerät, Palette *Firmware-Hinweise*): OSV kennt keine Hersteller-Firmware, deshalb fragt sshTermy die NVD (NIST) nach allen CVEs des Produkts (FortiOS, Cisco IOS/IOS XE/NX-OS/ASA, Junos, RouterOS, ArubaOS-Switch/CX, PAN-OS, Arista EOS, SonicOS, OPNsense, pfSense, Sophos, WatchGuard, EXOS, EdgeOS) und prüft die Version selbst. Gesendet wird nur der Produktname, nie die Firmware-Version oder das Gerät. Zeigt Bewertung, aktiv ausgenutzt (CISA KEV), *behoben ab*-Version und ob eine CVE nur bestimmte Modelle betrifft, dazu die Seite mit den Sicherheitsmeldungen des Herstellers. Die Ordner-Variante verbindet sich nicht: Sie nutzt Hersteller und Firmware, die F6 zuletzt gelesen hat. Welches NVD-Produkt zu einem Befehlssatz gehört, steht in dessen YAML (`advisory.cpe`) und lässt sich korrigieren oder ergänzen. Ein kostenloser NVD-API-Schlüssel (Einstellungen › *Sicherheitscheck*) macht es etwa zehnmal schneller; Ergebnisse bleiben 24 h im Zwischenspeicher.
- **Patch-Runde** (Palette *Patch-Runde*): spielt Updates gestaffelt über einen Ordner ein. Du wählst den Ordner, alle Updates oder nur die Pakete mit Lücken aus dem Sicherheitscheck, Neustart wenn nötig oder nicht, und den ersten Host (Test-Hosts werden zuerst vorgeschlagen). Nach zweimal `j` bekommt der erste Host die Updates allein; dann hält die Runde an und `w` setzt mit dem Rest fort, einer nach dem anderen. Vor und nach jedem Host vergleicht sshTermy laufende Dienste, lauschende Ports, fehlgeschlagene Units und neue Fehler im Log; Neustarts laufen einzeln und warten, bis der Host zurück ist (neue Boot-ID). Jede Auffälligkeit hält die Runde an. `x` beendet nach dem laufenden Host (nie mitten im Update), `c` kopiert den Bericht. Braucht root oder sudo (ohne Passwort, gespeichertes Passwort oder einmal gefragt).
- **Härtungs-Check** (`h` in F6, Palette *Härtungs-Check*): kurzer, nur lesender Check eines Linux-Servers: SSH (root-Login, Passwort-Login, leere Passwörter, MaxAuthTries, X11), sudo NOPASSWD für alles, Firewall an oder aus, Ports offen für alle Adressen, die das meist nicht sein sollten (Redis, MongoDB, Docker-API, Elasticsearch, Datenbanken, Telnet …), automatische Sicherheitsupdates, weitere Konten mit UID 0, Konten ohne Passwort, TLS-Zertifikate auf dem Host (Let's Encrypt, nginx, Apache) abgelaufen oder in unter 30 Tagen fällig, Zeitabgleich. Ampel rot/gelb/Hinweis mit Vorschlag je Punkt; sshTermy ändert nichts. Mit `sudo -n` sieht er mehr (sshd -T, sudoers, Firewall-Regeln). In F6 steht eine Zeile *Härtung*; die Palette prüft einen ganzen Ordner (4 gleichzeitig, eine Zeile pro Host, `c` kopiert als Markdown).
- **Schlüssel-Inventar** (`a` in F6, Palette *Schlüssel-Inventar*): welche öffentlichen SSH-Schlüssel in welchen `authorized_keys` stehen, auf einem Host oder einem ganzen Ordner (mit `sudo -n` alle Benutzer, sonst nur der eigene). Ein Eintrag pro Schlüssel mit Name/Kommentar, Typ und den Hosts und Benutzern, bei denen er steht; veraltete Schlüssel (DSA, RSA unter 2048 Bit) stehen oben, Schlüssel dieses Rechners sind markiert. Tippen sucht nach Name oder Host. ⏎ zeigt, wo ein Schlüssel steht, `d` entfernt ihn von allen diesen Hosts: zweimal `j`, dann jeden Host einzeln bestätigen (`n` lässt ihn aus); jede Datei wird vorher nach `<datei>.sshtermy-<Zeit>` kopiert und behält Besitzer und Rechte. Den Schlüssel, mit dem sich sshTermy selbst an einem Host anmeldet, entfernt es dort nie.
- **Config-Sicherung für Switches**: `b` sichert die laufende Konfiguration (`show running-config`; Junos `show configuration | display set`, RouterOS `/export`, FortiOS `show full-configuration`, UniFi `cat /tmp/system.cfg`) verschlüsselt auf dem Rechner, `d` zeigt den Diff zum vorherigen Stand, unveränderte Stände werden nicht doppelt gespeichert.
Nächtlich geht es per Zeitplan (`z`, Art „Config-Sicherung“) für einen ganzen Ordner. **Regeln für Switch-Configs**
(Palette → Einstellungen): `+^ntp server` muss vorkommen, `-telnet-server` darf nicht; jede Sicherung wird geprüft,
@@ -352,7 +354,7 @@ sshtermy mcp # MCP-Server für KI-Clients (stdin/stdout), siehe „
| | F3 | KI fragen (Esc bricht die Antwort ab, n neue Frage, f Folgefrage, u Fix nach Fehler übernehmen) |
| | F4 | Tunnel an/aus (⏎ oder Klick), a mit Verbindung starten, Web-Service im Browser öffnen |
| | F5 | Dateien (SFTP): Tab Seite, ⏎/Doppelklick öffnen bzw. ansehen, c kopieren (hoch/runter), e eigener Editor, o Standardprogramm, Leertaste/a markieren, Strg/Umschalt+Klick markieren, Ziehen kopiert, Rechtsklick Menü, F2 umbenennen, y Pfad kopieren, s sortieren, v Vorschau, n Ordner, d löschen, . versteckte; „permission denied“ → j j wiederholt mit sudo; im Betrachter / suchen, f mitlesen, w umbrechen |
| | F6 | Host-Übersicht: r/⏎ abfragen, t Zeitraum der Graphen 5 min/1 h, z groß, l Log-Blick, s Sicherheitscheck (OSV), c Container, b Switch-Config sichern, ↑↓ Stand, d Diff, v ansehen |
| | F6 | Host-Übersicht: r/⏎ abfragen, t Zeitraum der Graphen 5 min/1 h, z groß, l Log-Blick, s Sicherheitscheck (OSV), h Härtungs-Check, a Schlüssel-Inventar, c Container, b Switch-Config sichern, ↑↓ Stand, d Diff, v ansehen |
| | F7 / F8 | vorheriger / nächster Tab |
| | Alt+T | alle Tabs (Liste: springen, schließen, umbenennen, duplizieren, verschieben) |
| | Alt+S | in allen offenen Tabs suchen, ⏎ springt zur Trefferzeile |
@@ -374,6 +376,7 @@ sshtermy mcp # MCP-Server für KI-Clients (stdin/stdout), siehe „
| | Alt+E | Log-Blick: Auffälligkeiten in den Logs (⏎ Zeilen, 1…4 prüfen, k KI erklärt, b KI-Lagebericht, x/X ausblenden, n Was ist neu?, t Zeitleiste, z Zeitraum, w Logwache, s Syslog am Switch einrichten) |
| | F6 → s | am Switch/an der Firewall: Firmware-Hinweise (NVD), c kopieren · am Server: Sicherheitscheck (OSV): ⏎ Details, u Update-Befehl einfügen, k KI erklärt, f nur reparierbare, x/X für Host/Ordner hinnehmen, n hingenommene, r neu, o Ordner, c kopieren |
| | Palette *Patch-Runde* | Updates gestaffelt über einen Ordner: j j starten, w nach dem ersten Host weiter, x nach dem laufenden Host beenden, c Bericht kopieren |
| | F6 → h / a | Härtungs-Check (nur lesend, c kopieren) / Schlüssel-Inventar: ⏎ wo steht der Schlüssel, d entfernen (j j, dann je Host j/n), ← zurück zur Liste |
| | Alt+K / Alt+J | KI-Begleiter: Stufe Aus · Leise · Gesprächig · Coach / Begleiter-Leiste |
| | Alt+V | Vorgang über mehrere Fenster: die KI sieht alle verbundenen Fenster |
| Vorgang (Alt+V) | Leertaste / ← → / ⏎ | Fenster wählen / was die KI sieht / Vorgang starten, Frage senden |
+4 -1
View File
@@ -70,6 +70,8 @@ lets them in. The AI status report treats syslog lines as hints, not as proof. T
- **Security check (OSV)** (`s` in F6, palette *Security check*): reads the installed packages of a Linux server over the open session, read-only (Debian/Ubuntu, RHEL/Rocky/Alma, SUSE, Alpine; with `sudo -n` also running Docker/Podman containers), and compares them with the public [OSV](https://osv.dev) database. Only package names and versions leave your computer, never host names or terminal content. The result lists only what matters: per package the highest score, whether a fixed version exists, whether the CVE is on the CISA list of actively exploited vulnerabilities (KEV) and whether a running service with an open port uses it (`sshd :22`). Findings the distribution rates as minor are counted but not shown. ⏎ details, `u` inserts the update command for that package at the prompt (not run), `k` lets the AI explain the risk in plain words, `f` only fixable, `x`/`X` accept a finding for the host or the whole folder (comes back when a new CVE appears), `n` shows accepted ones, `c` copies as Markdown. F6 shows a *Security* line with the last result. First use asks *online* (asks the OSV API, small) or *offline* (downloads the database per distribution once a day, e.g. 80 MB for Debian; nothing about your packages leaves the computer); Settings › *Security check (OSV)* changes it and sets a company mirror. Palette *Security check: all servers in folder* checks a whole folder (4 at a time, one line per host); as a schedule (kind *Security check (OSV)*) it runs e.g. weekly and only notifies when something new is high, critical or KEV.
- **Firmware advisories for switches and firewalls** (`s` in F6 on a network device, palette *Firmware advisories*): OSV does not know vendor firmware, so sshTermy asks the NVD (NIST) for all CVEs of the product (FortiOS, Cisco IOS/IOS XE/NX-OS/ASA, Junos, RouterOS, ArubaOS-Switch/CX, PAN-OS, Arista EOS, SonicOS, OPNsense, pfSense, Sophos, WatchGuard, EXOS, EdgeOS) and checks the version itself. Only the product name is sent, never the firmware version or the device. Shows score, actively exploited (CISA KEV), *fixed in* version and whether a CVE only affects certain models, plus the vendor's advisory page. The folder variant does not connect: it uses vendor and firmware as last read by F6. Which NVD product belongs to a command set is in its YAML (`advisory.cpe`), so you can fix or add it. Optional free NVD API key (Settings › *Security check*) makes it about ten times faster; results are cached for 24 h.
- **Patch round** (palette *Patch round*): installs updates across a folder in stages. You choose the folder, all updates or only the packages with vulnerabilities from the security check, reboot if needed or not, and the first host (test hosts are suggested first). After pressing `j` twice, the first host gets the updates alone; then the round pauses and `w` continues with the rest, one after the other. Before and after each host sshTermy compares running services, listening ports, failed units and new errors in the log; reboots happen one at a time and wait for the host to come back (new boot ID). Any finding pauses the round. `x` stops after the current host (never in the middle of an update), `c` copies the report. Needs root or sudo (without password, stored password, or asked once).
- **Hardening check** (`h` in F6, palette *Hardening check*): short read-only check of a Linux server: SSH (root login, password login, empty passwords, MaxAuthTries, X11), sudo NOPASSWD for everything, firewall on or off, ports open to all addresses that usually should not be (Redis, MongoDB, Docker API, Elasticsearch, databases, Telnet …), automatic security updates, other accounts with UID 0, accounts without password, TLS certificates on the host (Let's Encrypt, nginx, Apache) expired or expiring within 30 days, time sync. Traffic light red/yellow/notes with a suggestion for each point; sshTermy changes nothing. With `sudo -n` it sees more (sshd -T, sudoers, firewall rules). F6 shows a *Hardening* line; the palette checks a whole folder (4 at a time, one line per host, `c` copies as Markdown).
- **Key inventory** (`a` in F6, palette *Key inventory*): which public SSH keys are in which `authorized_keys`, on one host or a whole folder (all users with `sudo -n`, otherwise your own). One entry per key with name/comment, type and the hosts and users it is on; outdated keys (DSA, RSA under 2048 bits) come first, keys of this computer are marked. Type a name or host to search. ⏎ shows where a key is, `d` removes it from all those hosts: confirm with `j` twice, then each host separately (`n` skips it); each file is copied to `<file>.sshtermy-<time>` first and keeps its owner and permissions. The key sshTermy itself uses to sign in to a host is never removed there.
- **Config backup for switches**: `b` saves the running configuration (`show running-config`; Junos `show configuration | display set`, RouterOS `/export`, FortiOS `show full-configuration`, UniFi `cat /tmp/system.cfg`) encrypted on your computer, `d` shows the diff to the previous state, unchanged states are not stored twice.
Nightly runs go through a schedule (`z`, type “Config backup”) for a whole folder. **Switch config rules**
(palette → Settings): `+^ntp server` must appear, `-telnet-server` must not; every backup is checked,
@@ -342,7 +344,7 @@ sshtermy mcp # MCP server for AI clients (stdin/stdout), see “sshT
| | F3 | ask AI (Esc stops the answer, n new question, f follow-up, u use the fix after an error) |
| | F4 | tunnels on/off (⏎ or click), a start with connection, open a web service in the browser |
| | F5 | files (SFTP): Tab side, ⏎/double-click open or view, c copy (up/down), e own editor, o default app, Space/a mark, Ctrl/Shift+click mark, drag copies, right-click menu, F2 rename, y copy path, s sort, v preview, n folder, d delete, . hidden; “permission denied” → j j repeats with sudo; in the viewer / search, f follow, w wrap |
| | F6 | host overview: r/⏎ query, t graph range 5 min/1 h, z large, l log view, s security check (OSV), c containers, b back up switch config, ↑↓ state, d diff, v view |
| | F6 | host overview: r/⏎ query, t graph range 5 min/1 h, z large, l log view, s security check (OSV), h hardening check, a key inventory, c containers, b back up switch config, ↑↓ state, d diff, v view |
| | F7 / F8 | previous / next tab |
| | Alt+T | all tabs (list: jump, close, rename, duplicate, move) |
| | Alt+S | search in all open tabs, ⏎ jumps to the matching line |
@@ -364,6 +366,7 @@ sshtermy mcp # MCP server for AI clients (stdin/stdout), see “sshT
| | Alt+E | log view: anomalies in the logs (⏎ lines, 1…4 check, k AI explains, b AI status report, x/X hide, n what's new, t timeline, z period, w log watch, s syslog setup on switches) |
| | F6 → s | on a switch/firewall: firmware advisories (NVD), c copy · on a server: security check (OSV): ⏎ details, u insert update command, k AI explains, f only fixable, x/X accept for host/folder, n accepted, r again, o folder, c copy |
| | Palette *Patch round* | staged updates across a folder: j j start, w continue after the first host, x stop after the current host, c copy report |
| | F6 → h / a | hardening check (read-only, c copy) / key inventory: ⏎ where is the key, d remove (j j, then y/n per host), ← back to list |
| | Alt+K / Alt+J | AI companion: level off · quiet · chatty · coach / companion sidebar |
| | Alt+V | task across several windows: the AI sees all linked windows |
| Task (Alt+V) | Space / ← → / ⏎ | choose windows / what the AI sees / start task, send question |
+388
View File
@@ -0,0 +1,388 @@
// Package harden: kurzer, nur lesender Härtungs-Check für Linux-Server.
//
// Ein Skript sammelt Fakten (sshd-Einstellungen, sudo NOPASSWD, Firewall,
// lauschende Ports, automatische Updates, TLS-Zertifikate, Konten mit UID 0,
// Zeitabgleich, MAC-Schutz). Die Bewertung passiert hier, lokal. Nichts wird
// geändert; Vorschläge zum Beheben stehen als Text dabei.
package harden
import (
"fmt"
"sort"
"strconv"
"strings"
"time"
"github.com/db9979/sshtermy/internal/i18n"
)
// Level: Ampel.
type Level int
const (
OK Level = iota
Info
Warn
Bad
)
// Finding: ein Prüfpunkt.
type Finding struct {
ID string `json:"id"`
Level Level `json:"level"`
Title string `json:"title"`
Detail string `json:"detail,omitempty"`
Fix string `json:"fix,omitempty"` // Vorschlag, nie automatisch
}
// Report: Ergebnis eines Hosts.
type Report struct {
At time.Time `json:"at"`
System string `json:"system,omitempty"`
Root bool `json:"root,omitempty"` // mit root-Rechten gelesen (sonst lückenhaft)
Findings []Finding `json:"findings"`
}
// Counts: rot, gelb, Hinweise.
func (r *Report) Counts() (bad, warn, info int) {
if r == nil {
return
}
for _, f := range r.Findings {
switch f.Level {
case Bad:
bad++
case Warn:
warn++
case Info:
info++
}
}
return
}
// Script liest nur. Mit root (oder sudo -n) sieht es mehr.
const Script = `export LC_ALL=C
P=""
if [ "$(id -u)" = 0 ]; then echo "root=1"; elif sudo -n true 2>/dev/null; then P="sudo -n"; echo "root=1"; fi
. /etc/os-release 2>/dev/null && echo "os=$PRETTY_NAME"
if command -v sshd >/dev/null 2>&1 || [ -x /usr/sbin/sshd ]; then
S=$(command -v sshd || echo /usr/sbin/sshd)
$P $S -T 2>/dev/null | grep -Ei '^(permitrootlogin|passwordauthentication|permitemptypasswords|x11forwarding|maxauthtries|kbdinteractiveauthentication|pubkeyauthentication) ' | sed 's/^/sshd=/'
fi
$P cat /etc/sudoers /etc/sudoers.d/* 2>/dev/null | grep -v '^[[:space:]]*#' | grep -E 'NOPASSWD' | sed 's/^/nopasswd=/' | head -20
if command -v ufw >/dev/null 2>&1; then echo "fw=ufw $($P ufw status 2>/dev/null | head -1)"; fi
if command -v firewall-cmd >/dev/null 2>&1; then echo "fw=firewalld $(firewall-cmd --state 2>&1 | head -1)"; fi
if command -v nft >/dev/null 2>&1; then echo "fw=nft $($P nft list ruleset 2>/dev/null | grep -cE '^\s*(chain|.*(drop|reject))' )"; fi
if command -v iptables >/dev/null 2>&1; then echo "fw=iptables $($P iptables -S 2>/dev/null | grep -cvE '^-P (INPUT|FORWARD|OUTPUT) ACCEPT$')"; fi
$P iptables -S INPUT 2>/dev/null | head -1 | sed 's/^/fwpol=/'
if command -v ss >/dev/null 2>&1; then ss -ltnpH 2>/dev/null | awk '{print "lis="$4"|"$6}' | head -60; fi
if [ -f /etc/apt/apt.conf.d/20auto-upgrades ]; then grep -h 'Unattended-Upgrade' /etc/apt/apt.conf.d/20auto-upgrades /etc/apt/apt.conf.d/10periodic 2>/dev/null | sed 's/^/auto=apt /'; fi
command -v unattended-upgrade >/dev/null 2>&1 && echo "auto=apt-installed"
if command -v systemctl >/dev/null 2>&1; then
for t in dnf-automatic.timer dnf-automatic-install.timer dnf5-automatic.timer yum-cron.service apt-daily-upgrade.timer; do
systemctl is-enabled "$t" >/dev/null 2>&1 && echo "auto=unit $t"
done
for u in fail2ban.service sshguard.service crowdsec.service; do
systemctl is-active "$u" >/dev/null 2>&1 && echo "guard=$u"
done
fi
command -v timedatectl >/dev/null 2>&1 && timedatectl show -p NTPSynchronized --value 2>/dev/null | sed 's/^/ntp=/'
[ -r /sys/fs/selinux/enforce ] && echo "selinux=$(cat /sys/fs/selinux/enforce)"
[ -d /sys/kernel/security/apparmor ] && echo "apparmor=1"
awk -F: '$3==0 {print "uid0="$1}' /etc/passwd 2>/dev/null
$P awk -F: '($2=="") {print "emptypw="$1}' /etc/shadow 2>/dev/null | head -10
for f in $( ( ls /etc/letsencrypt/live/*/cert.pem 2>/dev/null; $P grep -rhoE '^\s*(ssl_certificate|SSLCertificateFile)\s+[^ ;]+' /etc/nginx /etc/apache2 /etc/httpd 2>/dev/null | awk '{print $2}' ) | sort -u | head -30); do
e=$($P openssl x509 -enddate -noout -in "$f" 2>/dev/null | cut -d= -f2)
[ -n "$e" ] && echo "cert=$f|$e"
done
exit 0
`
// Facts: gelesene Fakten.
type Facts struct {
Root bool
OS string
SSHD map[string]string
NoPasswd []string
FW []string // "ufw Status: active", "firewalld running", "nft 12", "iptables 3"
FWPolicy string
Listen []Listener
Auto []string
Guards []string
NTP string
SELinux string
AppArmor bool
UID0 []string
EmptyPW []string
Certs []Cert
}
// Listener: lauschender TCP-Port.
type Listener struct {
Addr string
Port int
Proc string
}
// Cert: Zertifikat auf dem Host.
type Cert struct {
Path string
End time.Time
}
// Parse liest die Ausgabe von Script.
func Parse(out string) Facts {
f := Facts{SSHD: map[string]string{}}
for _, ln := range strings.Split(out, "\n") {
k, v, ok := strings.Cut(strings.TrimRight(ln, "\r"), "=")
if !ok {
continue
}
v = strings.TrimSpace(v)
switch k {
case "root":
f.Root = v == "1"
case "os":
f.OS = v
case "sshd":
if a, b, ok := strings.Cut(v, " "); ok {
f.SSHD[strings.ToLower(a)] = strings.ToLower(strings.TrimSpace(b))
}
case "nopasswd":
f.NoPasswd = append(f.NoPasswd, v)
case "fw":
f.FW = append(f.FW, v)
case "fwpol":
f.FWPolicy = v
case "lis":
addr, proc, _ := strings.Cut(v, "|")
if i := strings.LastIndexByte(addr, ':'); i > 0 {
p, _ := strconv.Atoi(addr[i+1:])
f.Listen = append(f.Listen, Listener{Addr: strings.Trim(addr[:i], "[]"), Port: p, Proc: procName(proc)})
}
case "auto":
f.Auto = append(f.Auto, v)
case "guard":
f.Guards = append(f.Guards, v)
case "ntp":
f.NTP = v
case "selinux":
f.SELinux = v
case "apparmor":
f.AppArmor = v == "1"
case "uid0":
f.UID0 = append(f.UID0, v)
case "emptypw":
f.EmptyPW = append(f.EmptyPW, v)
case "cert":
p, e, _ := strings.Cut(v, "|")
if t, err := time.Parse("Jan _2 15:04:05 2006 MST", e); err == nil {
f.Certs = append(f.Certs, Cert{Path: p, End: t})
}
}
}
return f
}
// procName: users:(("nginx",pid=1,fd=6)) → nginx
func procName(s string) string {
if i := strings.Index(s, `(("`); i >= 0 {
s = s[i+3:]
if j := strings.IndexByte(s, '"'); j >= 0 {
return s[:j]
}
}
return ""
}
// Ports, die nicht offen im Netz stehen sollten (unverschlüsselt oder ohne
// Anmeldung üblich).
var riskyPorts = map[int]string{
23: "Telnet", 2375: "Docker-API ohne TLS", 6379: "Redis", 11211: "Memcached", 27017: "MongoDB",
9200: "Elasticsearch", 5432: "PostgreSQL", 3306: "MySQL/MariaDB", 5984: "CouchDB", 2379: "etcd",
10250: "Kubelet", 8500: "Consul", 5900: "VNC", 21: "FTP", 111: "rpcbind", 445: "SMB", 139: "NetBIOS",
}
var critPorts = map[int]bool{23: true, 2375: true, 6379: true, 11211: true, 27017: true, 9200: true, 2379: true, 10250: true}
// Check bewertet die Fakten.
func Check(f Facts, now time.Time) *Report {
r := &Report{At: now, System: f.OS, Root: f.Root}
add := func(id string, lv Level, title, detail, fix string) {
r.Findings = append(r.Findings, Finding{ID: id, Level: lv, Title: title, Detail: detail, Fix: fix})
}
T := i18n.T
// sshd
if len(f.SSHD) == 0 {
add("sshd", Info, T("sshd-Einstellungen nicht lesbar"), T("„sshd -T“ braucht root; ohne sudo -n bleibt dieser Teil leer."), "")
} else {
switch f.SSHD["permitrootlogin"] {
case "yes":
add("ssh-root", Bad, T("SSH: root darf sich mit Passwort anmelden"), "PermitRootLogin yes",
T("In /etc/ssh/sshd_config „PermitRootLogin prohibit-password“ (oder no) setzen, dann sshd neu laden. Vorher prüfen, dass ein Schlüssel-Login funktioniert."))
case "prohibit-password", "without-password":
add("ssh-root", Info, T("SSH: root nur mit Schlüssel"), "PermitRootLogin "+f.SSHD["permitrootlogin"], T("Besser: Anmeldung als normaler Benutzer, dann sudo."))
default:
add("ssh-root", OK, T("SSH: root-Anmeldung aus"), "PermitRootLogin "+orDash(f.SSHD["permitrootlogin"]), "")
}
if f.SSHD["permitemptypasswords"] == "yes" {
add("ssh-empty", Bad, T("SSH: leere Passwörter erlaubt"), "PermitEmptyPasswords yes", T("„PermitEmptyPasswords no“ setzen."))
}
if f.SSHD["passwordauthentication"] == "yes" || f.SSHD["kbdinteractiveauthentication"] == "yes" {
lv := Warn
d := "PasswordAuthentication yes"
if len(f.Guards) > 0 {
d += " · " + strings.Join(f.Guards, ", ")
}
add("ssh-pw", lv, T("SSH: Anmeldung mit Passwort möglich"), d,
T("Wenn alle mit Schlüssel arbeiten: „PasswordAuthentication no“ und „KbdInteractiveAuthentication no“. Sonst fail2ban o. Ä. gegen Raten."))
} else {
add("ssh-pw", OK, T("SSH: nur Schlüssel-Anmeldung"), "", "")
}
if n, err := strconv.Atoi(f.SSHD["maxauthtries"]); err == nil && n > 6 {
add("ssh-tries", Info, T("SSH: viele Anmeldeversuche je Verbindung"), fmt.Sprintf("MaxAuthTries %d", n), T("„MaxAuthTries 4“ reicht meist."))
}
if f.SSHD["x11forwarding"] == "yes" {
add("ssh-x11", Info, T("SSH: X11-Weiterleitung an"), "X11Forwarding yes", T("Auf Servern ohne Grafik „X11Forwarding no“."))
}
}
// sudo
var all []string
for _, l := range f.NoPasswd {
if strings.Contains(l, "ALL") && !strings.Contains(l, "/") {
all = append(all, strings.Join(strings.Fields(l), " "))
}
}
if len(all) > 0 {
add("sudo-nopw", Warn, T("sudo ohne Passwort für alle Befehle"), strings.Join(all, " · "),
T("NOPASSWD nur für einzelne Befehle freigeben oder Passwort verlangen (visudo)."))
}
// Firewall
active := false
var fwd []string
for _, x := range f.FW {
lx := strings.ToLower(x)
switch {
case strings.HasPrefix(lx, "ufw") && strings.Contains(lx, "active") && !strings.Contains(lx, "inactive"):
active = true
case strings.HasPrefix(lx, "firewalld") && strings.Contains(lx, "running"):
active = true
case strings.HasPrefix(lx, "nft "), strings.HasPrefix(lx, "iptables "):
if n, _ := strconv.Atoi(strings.TrimSpace(x[strings.IndexByte(x, ' ')+1:])); n > 2 {
active = true
}
}
fwd = append(fwd, x)
}
if strings.Contains(f.FWPolicy, "DROP") || strings.Contains(f.FWPolicy, "REJECT") {
active = true
}
public := publicListeners(f.Listen)
switch {
case active:
add("fw", OK, T("Firewall aktiv"), strings.Join(fwd, " · "), "")
case !f.Root && len(f.FW) > 0:
add("fw", Info, T("Firewall-Regeln nicht lesbar (braucht root)"), strings.Join(fwd, " · "), "")
case len(public) > 1:
add("fw", Warn, T("Keine Firewall erkannt"), fmt.Sprintf(T("%d Ports offen für alle Adressen"), len(public)),
T("ufw bzw. firewalld einschalten und nur die nötigen Ports freigeben. Vorher SSH freigeben, sonst sperrst du dich aus."))
default:
add("fw", Info, T("Keine Firewall erkannt"), T("nur SSH offen"), "")
}
// Ports
for _, l := range public {
if name, ok := riskyPorts[l.Port]; ok {
lv := Warn
if critPorts[l.Port] {
lv = Bad
}
add(fmt.Sprintf("port-%d", l.Port), lv, fmt.Sprintf(T("Port %d (%s) offen für alle Adressen"), l.Port, name),
strings.TrimSpace(l.Addr+" "+l.Proc), T("Nur an 127.0.0.1 oder ein internes Netz binden oder per Firewall beschränken."))
}
}
// automatische Updates
auto := false
for _, a := range f.Auto {
la := strings.ToLower(a)
switch {
case strings.HasPrefix(la, "unit ") && !strings.Contains(la, "apt-daily-upgrade"):
auto = true // dnf-automatic, yum-cron
case strings.Contains(la, "unattended-upgrade") && strings.Contains(la, `"1"`):
auto = true
}
}
switch {
case auto:
add("auto", OK, T("Automatische Sicherheitsupdates an"), strings.Join(f.Auto, " · "), "")
default:
add("auto", Warn, T("Keine automatischen Sicherheitsupdates"), strings.Join(f.Auto, " · "),
T("Debian/Ubuntu: unattended-upgrades einrichten; RHEL-Familie: dnf-automatic (nur security). Alternativ Patch-Runde regelmäßig."))
}
// Konten
var extra []string
for _, u := range f.UID0 {
if u != "root" {
extra = append(extra, u)
}
}
if len(extra) > 0 {
add("uid0", Bad, T("Weitere Konten mit root-Rechten (UID 0)"), strings.Join(extra, ", "), T("Prüfen, wer das angelegt hat; UID 0 nur für root."))
}
if len(f.EmptyPW) > 0 {
add("emptypw", Bad, T("Konten ohne Passwort"), strings.Join(f.EmptyPW, ", "), T("Passwort setzen oder Konto sperren (passwd -l)."))
}
// Zertifikate
for _, c := range f.Certs {
days := int(c.End.Sub(now).Hours() / 24)
switch {
case days < 0:
add("cert", Bad, T("TLS-Zertifikat abgelaufen"), fmt.Sprintf("%s · %s", c.Path, c.End.Format("2006-01-02")), T("Zertifikat erneuern (certbot renew) und Dienst neu laden."))
case days < 14:
add("cert", Bad, fmt.Sprintf(T("TLS-Zertifikat läuft in %d Tagen ab"), days), c.Path, T("Erneuerung prüfen (certbot renew --dry-run)."))
case days < 30:
add("cert", Warn, fmt.Sprintf(T("TLS-Zertifikat läuft in %d Tagen ab"), days), c.Path, T("Erneuerung prüfen (certbot renew --dry-run)."))
}
}
// Kleinigkeiten
if f.NTP == "no" {
add("ntp", Info, T("Uhrzeit wird nicht abgeglichen"), "NTPSynchronized=no", T("chrony oder systemd-timesyncd einschalten; falsche Uhrzeit stört Logs und Zertifikate."))
}
if f.SELinux == "0" {
add("mac", Info, T("SELinux nur im Warnmodus"), "enforce=0", "")
}
sort.SliceStable(r.Findings, func(i, j int) bool { return r.Findings[i].Level > r.Findings[j].Level })
return r
}
func publicListeners(ls []Listener) []Listener {
seen := map[int]bool{}
var out []Listener
for _, l := range ls {
a := l.Addr
if a == "0.0.0.0" || a == "::" || a == "*" || a == "" {
if !seen[l.Port] {
seen[l.Port] = true
out = append(out, l)
}
}
}
sort.Slice(out, func(i, j int) bool { return out[i].Port < out[j].Port })
return out
}
func orDash(s string) string {
if s == "" {
return "–"
}
return s
}
+66
View File
@@ -0,0 +1,66 @@
package harden
import (
"strings"
"testing"
"time"
)
func TestCheck(t *testing.T) {
now := time.Date(2026, 11, 14, 12, 0, 0, 0, time.UTC)
out := `root=1
os=Debian GNU/Linux 12 (bookworm)
sshd=permitrootlogin yes
sshd=passwordauthentication yes
sshd=permitemptypasswords no
sshd=maxauthtries 10
nopasswd=deploy ALL=(ALL) NOPASSWD: ALL
nopasswd=backup ALL=(root) NOPASSWD: /usr/bin/rsync
fw=iptables 0
lis=0.0.0.0:22|users:(("sshd",pid=1,fd=3))
lis=[::]:22|users:(("sshd",pid=1,fd=4))
lis=0.0.0.0:6379|users:(("redis-server",pid=2,fd=6))
lis=127.0.0.1:5432|users:(("postgres",pid=3,fd=6))
lis=0.0.0.0:443|users:(("nginx",pid=4,fd=6))
auto=unit apt-daily-upgrade.timer
ntp=no
uid0=root
uid0=toor
cert=/etc/letsencrypt/live/web/cert.pem|Nov 20 10:00:00 2026 GMT
cert=/etc/ssl/old.pem|Jan 2 10:00:00 2026 GMT
`
r := Check(Parse(out), now)
ids := map[string]Level{}
for _, f := range r.Findings {
if _, ok := ids[f.ID]; !ok {
ids[f.ID] = f.Level
}
}
want := map[string]Level{"ssh-root": Bad, "ssh-pw": Warn, "ssh-tries": Info, "sudo-nopw": Warn, "fw": Warn, "port-6379": Bad,
"auto": Warn, "uid0": Bad, "cert": Bad, "ntp": Info}
for id, lv := range want {
if ids[id] != lv {
t.Errorf("%s: %v, will %v", id, ids[id], lv)
}
}
if _, ok := ids["port-5432"]; ok {
t.Error("Port an 127.0.0.1 gemeldet")
}
if r.Findings[0].Level != Bad {
t.Error("nicht nach Schwere sortiert")
}
b, w, _ := r.Counts()
if b < 4 || w < 3 {
t.Fatalf("%d %d", b, w)
}
for _, f := range r.Findings {
if f.ID == "sudo-nopw" && strings.Contains(f.Detail, "rsync") {
t.Error("NOPASSWD für einen Befehl gemeldet")
}
}
// sauberer Host
good := Check(Parse("root=1\nsshd=permitrootlogin no\nsshd=passwordauthentication no\nfw=ufw Status: active\nauto=apt APT::Periodic::Unattended-Upgrade \"1\";\nlis=0.0.0.0:22|\n"), now)
if b, w, _ := good.Counts(); b+w != 0 {
t.Fatalf("%+v", good.Findings)
}
}
+115
View File
@@ -0,0 +1,115 @@
package i18n
// Härtungs-Check und Schlüssel-Inventar (internal/harden, ui/harden.go,
// ui/keyinv.go).
func init() {
for k, v := range enHarden {
en[k] = v
}
}
var enHarden = map[string]string{
"Schlüssel-Inventar": "Key inventory",
"%d Ports offen für alle Adressen": "%d ports open to all addresses",
"Auf Servern ohne Grafik „X11Forwarding no“.": "On servers without graphics set “X11Forwarding no”.",
"Automatische Sicherheitsupdates an": "Automatic security updates on",
"Besser: Anmeldung als normaler Benutzer, dann sudo.": "Better: sign in as a normal user, then sudo.",
"Debian/Ubuntu: unattended-upgrades einrichten; RHEL-Familie: dnf-automatic (nur security). Alternativ Patch-Runde regelmäßig.": "Debian/Ubuntu: set up unattended-upgrades; RHEL family: dnf-automatic (security only). Or run a patch round regularly.",
"Erneuerung prüfen (certbot renew --dry-run).": "Check renewal (certbot renew --dry-run).",
"Firewall aktiv": "Firewall active",
"Firewall-Regeln nicht lesbar (braucht root)": "Firewall rules not readable (needs root)",
"In /etc/ssh/sshd_config „PermitRootLogin prohibit-password“ (oder no) setzen, dann sshd neu laden. Vorher prüfen, dass ein Schlüssel-Login funktioniert.": "Set “PermitRootLogin prohibit-password” (or no) in /etc/ssh/sshd_config, then reload sshd. Check first that a key login works.",
"Keine Firewall erkannt": "No firewall detected",
"Keine automatischen Sicherheitsupdates": "No automatic security updates",
"Konten ohne Passwort": "Accounts without password",
"NOPASSWD nur für einzelne Befehle freigeben oder Passwort verlangen (visudo).": "Allow NOPASSWD only for single commands or require a password (visudo).",
"Nur an 127.0.0.1 oder ein internes Netz binden oder per Firewall beschränken.": "Bind only to 127.0.0.1 or an internal network, or restrict with the firewall.",
"Passwort setzen oder Konto sperren (passwd -l).": "Set a password or lock the account (passwd -l).",
"Port %d (%s) offen für alle Adressen": "Port %d (%s) open to all addresses",
"Prüfen, wer das angelegt hat; UID 0 nur für root.": "Check who created it; UID 0 only for root.",
"SELinux nur im Warnmodus": "SELinux in permissive mode only",
"SSH: Anmeldung mit Passwort möglich": "SSH: password login possible",
"SSH: X11-Weiterleitung an": "SSH: X11 forwarding on",
"SSH: leere Passwörter erlaubt": "SSH: empty passwords allowed",
"SSH: nur Schlüssel-Anmeldung": "SSH: key login only",
"SSH: root darf sich mit Passwort anmelden": "SSH: root may log in with a password",
"SSH: root nur mit Schlüssel": "SSH: root with key only",
"SSH: root-Anmeldung aus": "SSH: root login off",
"SSH: viele Anmeldeversuche je Verbindung": "SSH: many login attempts per connection",
"TLS-Zertifikat abgelaufen": "TLS certificate expired",
"TLS-Zertifikat läuft in %d Tagen ab": "TLS certificate expires in %d days",
"Uhrzeit wird nicht abgeglichen": "Time is not synchronized",
"Weitere Konten mit root-Rechten (UID 0)": "Other accounts with root rights (UID 0)",
"Wenn alle mit Schlüssel arbeiten: „PasswordAuthentication no“ und „KbdInteractiveAuthentication no“. Sonst fail2ban o. Ä. gegen Raten.": "If everyone uses keys: “PasswordAuthentication no” and “KbdInteractiveAuthentication no”. Otherwise fail2ban or similar against guessing.",
"Zertifikat erneuern (certbot renew) und Dienst neu laden.": "Renew the certificate (certbot renew) and reload the service.",
"chrony oder systemd-timesyncd einschalten; falsche Uhrzeit stört Logs und Zertifikate.": "Enable chrony or systemd-timesyncd; a wrong clock breaks logs and certificates.",
"nur SSH offen": "only SSH open",
"sshd-Einstellungen nicht lesbar": "sshd settings not readable",
"sudo ohne Passwort für alle Befehle": "sudo without password for all commands",
"ufw bzw. firewalld einschalten und nur die nötigen Ports freigeben. Vorher SSH freigeben, sonst sperrst du dich aus.": "Enable ufw or firewalld and open only the needed ports. Allow SSH first, or you lock yourself out.",
"„MaxAuthTries 4“ reicht meist.": "“MaxAuthTries 4” is usually enough.",
"„PermitEmptyPasswords no“ setzen.": "Set “PermitEmptyPasswords no”.",
"„sshd -T“ braucht root; ohne sudo -n bleibt dieser Teil leer.": "“sshd -T” needs root; without sudo -n this part stays empty.",
"%d Hosts bleiben unverändert: sshTermy meldet sich dort mit genau diesem Schlüssel an.": "%d hosts stay unchanged: sshTermy signs in there with exactly this key.",
"%d Schlüssel auf %d Hosts gelesen": "%d keys read on %d hosts",
"%d gelb": "%d yellow",
"%d rot": "%d red",
"%s (%s)\n%s\n\nj = entfernen · n = diesen Host auslassen": "%s (%s)\n%s\n\ny = remove · n = skip this host",
"(ohne Namen)": "(no name)",
", %d nicht erreichbar": ", %d unreachable",
", %d nur eigener Benutzer (ohne sudo)": ", %d own user only (no sudo)",
"Darüber meldet sich sshTermy selbst an, nicht entfernt": "sshTermy signs in with it, not removed",
"Eigener Schlüssel dieses Rechners.": "Own key of this computer.",
"Einzelheiten mit Vorschlägen: Tab des Hosts öffnen, F6 › h.": "Details with suggestions: open the host's tab, F6 › h.",
"Härtung": "Hardening",
"Härtungs-Check geht nur bei Linux-Servern über SSH": "Hardening check works only for Linux servers over SSH",
"Härtungs-Check: ": "Hardening check: ",
"Härtungs-Check: alle Server im Ordner": "Hardening check: all servers in folder",
"Härtungs-Check: alle Server im Ordner …": "Hardening check: all servers in folder …",
"Härtungs-Check: letztes Ergebnis": "Hardening check: last result",
"Härtungs-Check: sshd, Firewall, Ports, Zertifikate": "Hardening check: sshd, firewall, ports, certificates",
"Keine Linux-Server (SSH) im Ordner": "No Linux servers (SSH) in the folder",
"Keine passenden Verbindungen": "No matching connections",
"Liest die authorized_keys aller Benutzer (mit sudo ohne Passwort, sonst nur die eigenen), nur lesend, ohne Rückfragen.": "Reads the authorized_keys of all users (with sudo without password, otherwise only your own), read-only, without prompts.",
"Name, Host oder Benutzer suchen …": "Search name, host or user …",
"Noch kein Schlüssel-Inventar gelesen": "No key inventory read yet",
"Nur lesend, ohne Rückfragen: Hosts, die ein Passwort oder eine Eingabe bräuchten, werden übersprungen. Mit sudo ohne Passwort sieht der Check mehr.": "Read-only, without prompts: hosts that would need a password or input are skipped. With sudo without password the check sees more.",
"Nur lesend. sshTermy ändert nichts; die Vorschläge setzt du selbst um.": "Read-only. sshTermy changes nothing; you apply the suggestions yourself.",
"Ohne sudo gelesen: sshd, sudo-Regeln und Firewall sind nur teilweise sichtbar.": "Read without sudo: sshd, sudo rules and firewall are only partly visible.",
"Schlüssel auf %s entfernen?": "Remove key on %s?",
"Schlüssel der Verbindung ": "Key of connection ",
"Schlüssel entfernen?": "Remove key?",
"Schlüssel entfernt auf: %s": "Key removed on: %s",
"Schlüssel lässt sich nicht sicher entfernen": "Key cannot be removed safely",
"Schlüssel-Inventar geht nur bei Servern über SSH": "Key inventory works only for servers over SSH",
"Schlüssel-Inventar: ": "Key inventory: ",
"Schlüssel-Inventar: Ordner wählen": "Key inventory: choose folder",
"Schlüssel-Inventar: authorized_keys dieses Hosts": "Key inventory: authorized_keys of this host",
"Schlüssel-Inventar: authorized_keys im Ordner …": "Key inventory: authorized_keys in folder …",
"Schlüssel-Inventar: lese %d Hosts …": "Key inventory: reading %d hosts …",
"Schlüssel-Inventar: letztes Ergebnis": "Key inventory: last result",
"Steht auf %d Hosts:": "Present on %d hosts:",
"Veraltet (%s): durch einen ed25519-Schlüssel ersetzen.": "Outdated (%s): replace with an ed25519 key.",
"d = von allen diesen Hosts entfernen (fragt je Host, mit Sicherungskopie) · ← zurück zur Liste · c kopieren": "d = remove from all these hosts (asks per host, with backup copy) · ← back to list · c copy",
"dieser Rechner: ": "this computer: ",
"entferne auf %s …": "removing on %s …",
"fremde authorized_keys brauchen sudo; kein passendes Passwort gespeichert": "other users' authorized_keys need sudo; no matching password saved",
"gelb": "yellow",
"in Ordnung": "fine",
"in Ordnung · %d Hinweise": "fine · %d notes",
"j = weiter · n = abbrechen": "y = continue · n = cancel",
"liest Einstellungen (nur lesend) …": "reading settings (read-only) …",
"nicht geprüft · h prüft (nur lesend)": "not checked · h checks (read-only)",
"nur lesend": "read-only",
"wer hat Zugang?": "who has access?",
"wichtigster Punkt": "top finding",
"| Host | Benutzer | Datei |\n|---|---|---|\n": "| Host | User | File |\n|---|---|---|\n",
"| Host | rot | gelb | wichtigster Punkt |\n|---|---|---|---|\n": "| Host | red | yellow | top finding |\n|---|---|---|---|\n",
"„%s“ aus den authorized_keys von %d Hosts entfernen? Du bestätigst danach jeden Host einzeln. Vorher wird je Datei eine Kopie <datei>.sshtermy-<Zeit> angelegt.": "Remove “%s” from the authorized_keys of %d hosts? You then confirm each host separately. A copy <file>.sshtermy-<time> is made of each file first.",
"⏎ zeigt, wo ein Schlüssel steht; dort entfernt d ihn.": "⏎ shows where a key is; d removes it there.",
"Härtungs-Check / Schlüssel-Inventar": "hardening check / key inventory",
"wo steht der Schlüssel?": "where is the key?",
"entfernen (je Host j, mit Kopie)": "remove (y per host, with copy)",
"zurück zur Liste": "back to list",
}
+248
View File
@@ -0,0 +1,248 @@
// Package keyinv: Schlüssel-Inventar. Welche öffentlichen SSH-Schlüssel
// stehen in welchen authorized_keys? Lesen geht nur lesend; Entfernen nur
// nach Bestätigung je Host, mit Sicherungskopie der Datei.
package keyinv
import (
"crypto/rsa"
"encoding/base64"
"fmt"
"sort"
"strings"
"golang.org/x/crypto/ssh"
)
// Script liest alle authorized_keys (mit root bzw. sudo -n die aller
// Benutzer, sonst nur die eigenen). Ausgabe:
//
// root=1
// key=<benutzer>|<datei>|<zeile>
const Script = `export LC_ALL=C
P=""
if [ "$(id -u)" = 0 ]; then echo "root=1"; elif sudo -n true 2>/dev/null; then P="sudo -n"; echo "root=1"; fi
emit() { u="$1"; f="$2"; $P cat "$f" 2>/dev/null | while IFS= read -r l || [ -n "$l" ]; do
case "$l" in ''|'#'*) continue;; esac; printf 'key=%s|%s|%s\n' "$u" "$f" "$l"; done; }
if [ -n "$P" ] || [ "$(id -u)" = 0 ]; then
getent passwd 2>/dev/null >/dev/null && PW="getent passwd" || PW="cat /etc/passwd"
$PW | while IFS=: read -r u x uid gid g h sh; do
[ -n "$h" ] || continue
for f in "$h/.ssh/authorized_keys" "$h/.ssh/authorized_keys2"; do
$P test -f "$f" 2>/dev/null && emit "$u" "$f"
done
done
for f in /etc/ssh/authorized_keys/* ; do [ -f "$f" ] && emit "$(basename "$f")" "$f"; done
else
for f in "$HOME/.ssh/authorized_keys" "$HOME/.ssh/authorized_keys2"; do [ -f "$f" ] && emit "$(id -un)" "$f"; done
fi
exit 0
`
// Entry: ein Schlüssel in einer Datei.
type Entry struct {
User string `json:"user"`
File string `json:"file"`
Type string `json:"type"`
Bits int `json:"bits,omitempty"`
FP string `json:"fp"` // SHA256:…
Blob string `json:"blob"` // base64 wie in der Datei (zum Entfernen)
Comment string `json:"comment,omitempty"`
Options string `json:"options,omitempty"`
}
// Host: Ergebnis eines Hosts.
type Host struct {
Root bool `json:"root,omitempty"`
Entries []Entry `json:"entries"`
Bad int `json:"bad,omitempty"` // unlesbare Zeilen
}
// Parse liest die Ausgabe von Script.
func Parse(out string) Host {
var h Host
for _, ln := range strings.Split(out, "\n") {
ln = strings.TrimRight(ln, "\r")
switch {
case ln == "root=1":
h.Root = true
case strings.HasPrefix(ln, "key="):
parts := strings.SplitN(ln[4:], "|", 3)
if len(parts) != 3 {
continue
}
e, ok := ParseLine(parts[2])
if !ok {
h.Bad++
continue
}
e.User, e.File = parts[0], parts[1]
h.Entries = append(h.Entries, e)
}
}
return h
}
// ParseLine: eine Zeile aus authorized_keys.
func ParseLine(line string) (Entry, bool) {
pk, comment, opts, _, err := ssh.ParseAuthorizedKey([]byte(line))
if err != nil {
return Entry{}, false
}
e := Entry{Type: pk.Type(), FP: ssh.FingerprintSHA256(pk), Comment: comment, Options: strings.Join(opts, ",")}
e.Blob = base64.StdEncoding.EncodeToString(pk.Marshal())
e.Bits = bits(pk)
return e, true
}
func bits(pk ssh.PublicKey) int {
if cpk, ok := pk.(ssh.CryptoPublicKey); ok {
if r, ok := cpk.CryptoPublicKey().(*rsa.PublicKey); ok {
return r.N.BitLen()
}
}
switch pk.Type() {
case ssh.KeyAlgoED25519, ssh.KeyAlgoSKED25519:
return 256
case ssh.KeyAlgoECDSA256, ssh.KeyAlgoSKECDSA256:
return 256
case ssh.KeyAlgoECDSA384:
return 384
case ssh.KeyAlgoECDSA521:
return 521
case "ssh-dss": // nur zum Erkennen alter Schlüssel
return 1024
}
return 0
}
// Weak: alter oder zu kurzer Schlüssel (Grund, "" = in Ordnung).
func (e Entry) Weak() string {
switch {
case e.Type == "ssh-dss":
return "DSA"
case e.Type == ssh.KeyAlgoRSA && e.Bits > 0 && e.Bits < 2048:
return fmt.Sprintf("RSA %d", e.Bits)
}
return ""
}
// Place: wo ein Schlüssel steht.
type Place struct {
Host string `json:"host"` // Verbindung (Alias)
ID string `json:"id"` // Verbindungs-ID
User string `json:"user"`
File string `json:"file"`
}
// Key: ein Schlüssel über alle Hosts.
type Key struct {
FP string `json:"fp"`
Type string `json:"type"`
Bits int `json:"bits,omitempty"`
Blob string `json:"blob"`
Comments []string `json:"comments,omitempty"`
Places []Place `json:"places"`
Own string `json:"own,omitempty"` // eigener Schlüssel dieses Rechners (Datei/Name)
}
// Hosts: Zahl verschiedener Hosts.
func (k Key) Hosts() int {
seen := map[string]bool{}
for _, p := range k.Places {
seen[p.ID] = true
}
return len(seen)
}
// Weak wie Entry.Weak.
func (k Key) Weak() string { return Entry{Type: k.Type, Bits: k.Bits}.Weak() }
// Label: Kommentar oder „ohne Namen“.
func (k Key) Label() string {
if k.Own != "" {
return k.Own
}
if len(k.Comments) > 0 {
return strings.Join(k.Comments, ", ")
}
return ""
}
// Merge fasst die Hosts zu Schlüsseln zusammen. own: Fingerabdruck →
// Name der eigenen Schlüssel dieses Rechners.
func Merge(hosts map[string]Host, names map[string]string, own map[string]string) []Key {
idx := map[string]*Key{}
var ids []string
for id := range hosts {
ids = append(ids, id)
}
sort.Strings(ids)
for _, id := range ids {
for _, e := range hosts[id].Entries {
k := idx[e.FP]
if k == nil {
k = &Key{FP: e.FP, Type: e.Type, Bits: e.Bits, Blob: e.Blob, Own: own[e.FP]}
idx[e.FP] = k
}
if e.Comment != "" && !contains(k.Comments, e.Comment) {
k.Comments = append(k.Comments, e.Comment)
}
k.Places = append(k.Places, Place{Host: names[id], ID: id, User: e.User, File: e.File})
}
}
out := make([]Key, 0, len(idx))
for _, k := range idx {
out = append(out, *k)
}
sort.SliceStable(out, func(i, j int) bool {
wi, wj := out[i].Weak() != "", out[j].Weak() != ""
if wi != wj {
return wi
}
if out[i].Hosts() != out[j].Hosts() {
return out[i].Hosts() > out[j].Hosts()
}
return out[i].FP < out[j].FP
})
return out
}
func contains(xs []string, s string) bool {
for _, x := range xs {
if x == s {
return true
}
}
return false
}
// RemoveScript: entfernt den Schlüssel (blob) aus der Datei. Legt vorher
// eine Kopie <datei>.sshtermy-<stamp> an und behält Rechte und Besitzer
// (Inhalt wird zurückgeschrieben, nicht ersetzt). Gibt „removed=N“ aus.
func RemoveScript(file, blob, stamp string) string {
q := func(s string) string { return "'" + strings.ReplaceAll(s, "'", `'\''`) + "'" }
return fmt.Sprintf(`set -e
f=%s; b=%s
[ -f "$f" ] || { echo "removed=0"; exit 0; }
n=$(grep -cF -- "$b" "$f" || true)
[ "$n" -gt 0 ] || { echo "removed=0"; exit 0; }
cp -p "$f" "$f.sshtermy-%s"
grep -vF -- "$b" "$f.sshtermy-%s" > "$f.sshtermy-tmp" || true
cat "$f.sshtermy-tmp" > "$f"
rm -f "$f.sshtermy-tmp"
echo "removed=$n"
`, q(file), q(blob), stamp, stamp)
}
// ValidBlob: nur base64 (schützt das Skript).
func ValidBlob(b string) bool {
if len(b) < 20 {
return false
}
for _, r := range b {
if !(r >= 'A' && r <= 'Z' || r >= 'a' && r <= 'z' || r >= '0' && r <= '9' || r == '+' || r == '/' || r == '=') {
return false
}
}
return true
}
+64
View File
@@ -0,0 +1,64 @@
package keyinv
import (
"crypto/ed25519"
"crypto/rand"
"crypto/rsa"
"strings"
"testing"
"golang.org/x/crypto/ssh"
)
func keyLine(t *testing.T, rsaBits int, comment string) string {
t.Helper()
var pub any
if rsaBits > 0 {
k, err := rsa.GenerateKey(rand.Reader, rsaBits)
if err != nil {
t.Fatal(err)
}
pub = &k.PublicKey
} else {
p, _, _ := ed25519.GenerateKey(rand.Reader)
pub = p
}
pk, err := ssh.NewPublicKey(pub)
if err != nil {
t.Fatal(err)
}
return strings.TrimSpace(string(ssh.MarshalAuthorizedKey(pk))) + " " + comment
}
func TestParseMerge(t *testing.T) {
alice := keyLine(t, 0, "alice@laptop")
old := keyLine(t, 1024, "old")
out1 := "root=1\nkey=root|/root/.ssh/authorized_keys|" + alice + "\nkey=deploy|/home/deploy/.ssh/authorized_keys|from=\"10.0.0.1\" " + old + "\nkey=root|/root/.ssh/authorized_keys|kaputt\n"
out2 := "key=root|/root/.ssh/authorized_keys|" + alice + "\n"
h1, h2 := Parse(out1), Parse(out2)
if !h1.Root || len(h1.Entries) != 2 || h1.Bad != 1 || h2.Root {
t.Fatalf("%+v %+v", h1, h2)
}
if h1.Entries[1].Options != `from="10.0.0.1"` || h1.Entries[1].Bits != 1024 || h1.Entries[1].Weak() != "RSA 1024" {
t.Fatalf("%+v", h1.Entries[1])
}
own := map[string]string{h1.Entries[0].FP: "sshTermy (id_ed25519)"}
keys := Merge(map[string]Host{"a": h1, "b": h2}, map[string]string{"a": "web01", "b": "web02"}, own)
if len(keys) != 2 || keys[0].Weak() == "" {
t.Fatalf("schwache zuerst: %+v", keys)
}
if keys[1].Hosts() != 2 || keys[1].Own == "" || keys[1].Label() != "sshTermy (id_ed25519)" || keys[1].Places[0].Host != "web01" {
t.Fatalf("%+v", keys[1])
}
}
func TestRemoveScript(t *testing.T) {
b := "AAAAC3NzaC1lZDI1NTE5AAAAIExample+/="
if !ValidBlob(b) || ValidBlob("x'; rm -rf /") {
t.Fatal("ValidBlob")
}
s := RemoveScript("/home/o'neil/.ssh/authorized_keys", b, "20261114")
if !strings.Contains(s, `f='/home/o'\''neil/.ssh/authorized_keys'`) || !strings.Contains(s, "cp -p") || !strings.Contains(s, `cat "$f.sshtermy-tmp" > "$f"`) {
t.Fatal(s)
}
}
+13 -2
View File
@@ -2,9 +2,9 @@ package store
import (
"encoding/json"
"strings"
"os"
"path/filepath"
"strings"
)
// Letzter Sicherheitscheck (OSV) je Verbindung: Grundlage für die Zeile in
@@ -56,7 +56,7 @@ func (s *Store) VulnReports() map[string]json.RawMessage {
return out
}
for k, v := range s.vbase.m {
if !strings.HasPrefix(k, fwPrefix) {
if !strings.Contains(k, "|") { // „fw|…“, „hd|…“: andere Prüfungen
out[k] = v
}
}
@@ -103,3 +103,14 @@ func (s *Store) FirmwareReport(connID string) json.RawMessage {
func (s *Store) SetFirmwareReport(connID string, v json.RawMessage) error {
return s.SetVulnReport(fwPrefix+connID, v)
}
// ExtraReport: weitere Prüfungen je Verbindung in derselben Datei
// (kind „hd“ Härtungs-Check, „ki“ Schlüssel-Inventar).
func (s *Store) ExtraReport(kind, connID string) json.RawMessage {
return s.VulnReport(kind + "|" + connID)
}
// SetExtraReport speichert eine weitere Prüfung (nil löscht).
func (s *Store) SetExtraReport(kind, connID string, v json.RawMessage) error {
return s.SetVulnReport(kind+"|"+connID, v)
}
+8
View File
@@ -106,6 +106,8 @@ type App struct {
voff *vuln.Offline // Offline-Datenbank (bleibt im Speicher)
fwchk fwState // Firmware-Hinweise (firmware.go)
patch patchState // Patch-Runde (patchround.go)
hard hardenState // Härtungs-Check (harden.go)
kinv keyinvState // Schlüssel-Inventar (keyinv.go)
compUse companionUsage // Begleiter: Anfragen, Tokens (companion.go)
recap *recapState // Begleiter: laufender Rückblick
windowed bool // im eigenen Fenster (internal/gui), SetWindowed
@@ -641,6 +643,12 @@ func (a *App) featureMsg(msg tea.Msg) (tea.Cmd, bool) {
if cmd, ok := a.patchMsgs(msg); ok {
return cmd, true
}
if cmd, ok := a.hardenMsgs(msg); ok {
return cmd, true
}
if cmd, ok := a.keyinvMsgs(msg); ok {
return cmd, true
}
if cmd, ok := a.vulnFolderMsg(msg); ok {
return cmd, true
}
+386
View File
@@ -0,0 +1,386 @@
package ui
import (
"context"
"encoding/json"
"fmt"
"sort"
"strings"
"sync"
"time"
tea "charm.land/bubbletea/v2"
"github.com/db9979/sshtermy/internal/domain"
"github.com/db9979/sshtermy/internal/harden"
"github.com/db9979/sshtermy/internal/i18n"
)
// Härtungs-Check (F6 h, Palette „Härtungs-Check“): nur lesend, Bewertung
// lokal (internal/harden). Vorschläge stehen als Text dabei, geändert wird
// nichts.
type hardenHost struct {
conn domain.Connection
rep *harden.Report
err string
done bool
}
type hardenState struct {
seq int
busy bool
title string
single bool
hosts []hardenHost
cancel context.CancelFunc
}
type hardenMsg struct {
seq int
i int
rep *harden.Report
err error
viaCmd bool // kam als Rückgabe eines tea.Cmd, nicht über a.events
}
// hardenRunHost: Skript auf einem Host ohne Rückfragen (in Tests austauschbar).
var hardenRunHost = func(a *App) func(ctx context.Context, c domain.Connection, script string) (string, error) {
return a.quietScript
}
// quietScript: ohne Rückfragen verbinden und ein sh-Skript ausführen.
func (a *App) quietScript(ctx context.Context, c domain.Connection, script string) (string, error) {
ex, err := a.quietDialer()(ctx, c)
if err != nil {
return "", err
}
defer ex.Close()
rctx, cancel := context.WithTimeout(ctx, 3*time.Minute)
defer cancel()
res, err := ex.Exec(rctx, "sh -c "+shQuote(script))
if err != nil && len(res.Output) == 0 {
return "", err
}
return string(res.Output), nil
}
// forHosts: fn für alle Verbindungen, par gleichzeitig.
func forHosts(ctx context.Context, conns []domain.Connection, par int, fn func(context.Context, int, domain.Connection)) {
sem := make(chan struct{}, par)
var wg sync.WaitGroup
for i, c := range conns {
wg.Add(1)
go func() {
defer wg.Done()
select {
case sem <- struct{}{}:
case <-ctx.Done():
fn(ctx, i, c)
return
}
defer func() { <-sem }()
fn(ctx, i, c)
}()
}
wg.Wait()
}
// openHarden: F6 h am Server.
func (a *App) openHarden(s *session) tea.Cmd {
if s == nil || s.client == nil || s.netDevice() || s.isWinRM() || s.prof.Family == domain.FamilyWindows || !a.hostServerOK(s) {
s.host.err = i18n.T("Härtungs-Check geht nur bei Linux-Servern über SSH")
return nil
}
h := &a.hard
if h.cancel != nil {
h.cancel()
}
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Minute)
*h = hardenState{seq: h.seq + 1, busy: true, title: s.conn.Alias, single: true, hosts: []hardenHost{{conn: s.conn}}, cancel: cancel}
seq, cl := h.seq, s.client
a.showHarden()
return func() tea.Msg {
defer cancel()
out, err := cl.RunScript(ctx, harden.Script)
if err != nil && strings.TrimSpace(out) == "" {
return hardenMsg{seq: seq, err: err, viaCmd: true}
}
return hardenMsg{seq: seq, rep: harden.Check(harden.Parse(out), time.Now()), viaCmd: true}
}
}
func (a *App) openHardenFolder() tea.Cmd {
return a.folderPicker(i18n.T("Härtungs-Check: alle Server im Ordner"), vulnScanable,
i18n.T("Nur lesend, ohne Rückfragen: Hosts, die ein Passwort oder eine Eingabe bräuchten, werden übersprungen. Mit sudo ohne Passwort sieht der Check mehr."),
func(folder string) tea.Cmd { return a.runHardenFolder(folder) })
}
// folderPicker: Ordner mit passenden Verbindungen wählen.
func (a *App) folderPicker(title string, ok func(domain.Connection) bool, help string, run func(string) tea.Cmd) tea.Cmd {
count := map[string]int{}
for _, c := range a.st.Connections() {
if !ok(c) {
continue
}
count[""]++
p := c.Group
for p != "" {
count[p]++
i := strings.LastIndex(p, domain.PathSep)
if i < 0 {
break
}
p = p[:i]
}
}
if count[""] == 0 {
a.flash(i18n.T("Keine passenden Verbindungen"))
return nil
}
var paths []string
for p := range count {
if p != "" {
paths = append(paths, p)
}
}
sort.Strings(paths)
items := []pickItem{{value: "\x00all", label: i18n.T("Alle Verbindungen"), hint: fmt.Sprint(count[""])}}
for _, p := range paths {
items = append(items, pickItem{value: p, label: p, hint: fmt.Sprint(count[p]), indent: strings.Count(p, domain.PathSep)})
}
cur := ""
if a.scr == scrManager {
if r, ok := a.mgrCur(); ok {
if r.isFolder() {
cur = r.node.Path
} else {
cur = r.conn.Group
}
}
} else if s := a.current(); s != nil {
cur = s.conn.Group
}
a.pick = newPicker(title, i18n.T("Ordner suchen …"), items, cur, func(it pickItem) tea.Cmd {
f := it.value
if f == "\x00all" {
f = ""
}
return run(f)
})
a.pick.help = help
return nil
}
func (a *App) runHardenFolder(folder string) tea.Cmd {
conns := a.vulnFolderConns(folder)
if len(conns) == 0 {
a.flash(i18n.T("Keine Linux-Server (SSH) im Ordner"))
return nil
}
h := &a.hard
if h.cancel != nil {
h.cancel()
}
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Minute)
where := folder
if where == "" {
where = i18n.T("alle Verbindungen")
}
*h = hardenState{seq: h.seq + 1, busy: true, title: where, cancel: cancel}
for _, c := range conns {
h.hosts = append(h.hosts, hardenHost{conn: c})
}
seq, ev, run := h.seq, a.events, hardenRunHost(a)
go func() {
defer cancel()
forHosts(ctx, conns, 4, func(ctx context.Context, i int, c domain.Connection) {
if ctx.Err() != nil {
ev <- hardenMsg{seq: seq, i: i, err: ctx.Err()}
return
}
out, err := run(ctx, c, harden.Script)
if err != nil {
ev <- hardenMsg{seq: seq, i: i, err: err}
return
}
ev <- hardenMsg{seq: seq, i: i, rep: harden.Check(harden.Parse(out), time.Now())}
})
}()
a.showHarden()
return nil
}
func (a *App) hardenMsgs(msg tea.Msg) (tea.Cmd, bool) {
m, ok := msg.(hardenMsg)
if !ok {
return nil, false
}
h := &a.hard
next := a.listen()
if m.viaCmd {
next = nil
}
if m.seq != h.seq || m.i >= len(h.hosts) {
return next, true
}
x := &h.hosts[m.i]
x.done, x.rep = true, m.rep
if m.err != nil {
x.err = m.err.Error()
}
if m.rep != nil {
if raw, err := json.Marshal(m.rep); err == nil {
_ = a.st.SetExtraReport("hd", x.conn.ID, raw)
}
}
h.busy = false
for _, y := range h.hosts {
if !y.done {
h.busy = true
}
}
if a.modal != nil && a.modal.harden {
a.showHarden()
}
return next, true
}
func (a *App) storedHarden(connID string) *harden.Report {
raw := a.st.ExtraReport("hd", connID)
if len(raw) == 0 {
return nil
}
var r harden.Report
if json.Unmarshal(raw, &r) != nil {
return nil
}
return &r
}
func hardenIcon(l harden.Level) string {
switch l {
case harden.Bad:
return "×"
case harden.Warn:
return "▲"
case harden.Info:
return "i"
}
return "✓"
}
func hardenCountText(r *harden.Report) string {
b, w, i := r.Counts()
if b+w == 0 {
if i > 0 {
return fmt.Sprintf(i18n.T("in Ordnung · %d Hinweise"), i)
}
return i18n.T("in Ordnung")
}
var p []string
if b > 0 {
p = append(p, fmt.Sprintf(i18n.T("%d rot"), b))
}
if w > 0 {
p = append(p, fmt.Sprintf(i18n.T("%d gelb"), w))
}
return strings.Join(p, " · ")
}
func (a *App) showHarden() {
h := &a.hard
var lines []string
var md strings.Builder
title := i18n.T("Härtungs-Check: ") + h.title
fmt.Fprintf(&md, "# %s\n\n", title)
if h.busy {
lines = append(lines, spinGlyph(time.Now())+" "+i18n.T("liest Einstellungen (nur lesend) …"), "")
}
if h.single && len(h.hosts) == 1 {
x := h.hosts[0]
if x.err != "" {
lines = append(lines, "× "+x.err)
}
if r := x.rep; r != nil {
head := orDefault(r.System, x.conn.Alias) + " · " + hardenCountText(r)
lines = append(lines, head, "")
fmt.Fprintf(&md, "%s\n\n", head)
for _, f := range r.Findings {
lines = append(lines, hardenIcon(f.Level)+" "+f.Title)
fmt.Fprintf(&md, "- %s **%s**", hardenIcon(f.Level), f.Title)
if f.Detail != "" {
lines = append(lines, " "+trunc(f.Detail, 160))
fmt.Fprintf(&md, " (%s)", f.Detail)
}
if f.Fix != "" {
lines = append(lines, " → "+f.Fix)
fmt.Fprintf(&md, ": %s", f.Fix)
}
md.WriteString("\n")
}
if !r.Root {
lines = append(lines, "", i18n.T("Ohne sudo gelesen: sshd, sudo-Regeln und Firewall sind nur teilweise sichtbar."))
}
}
} else {
lines = append(lines, fmt.Sprintf("%-22s %4s %5s %s", "Host", i18n.T("rot"), i18n.T("gelb"), i18n.T("wichtigster Punkt")))
md.WriteString(i18n.T("| Host | rot | gelb | wichtigster Punkt |\n|---|---|---|---|\n"))
rows := append([]hardenHost(nil), h.hosts...)
sort.SliceStable(rows, func(i, j int) bool { return hardenRank(rows[i]) > hardenRank(rows[j]) })
for _, x := range rows {
name := trunc(x.conn.Alias, 22)
switch {
case !x.done:
lines = append(lines, fmt.Sprintf("%-22s %s", name, i18n.T("…")))
case x.rep == nil:
lines = append(lines, fmt.Sprintf("%-22s %4s %5s × %s", name, "", "", trunc(x.err, 60)))
fmt.Fprintf(&md, "| %s | | | × %s |\n", x.conn.Alias, x.err)
default:
b, w, _ := x.rep.Counts()
top := ""
if len(x.rep.Findings) > 0 && x.rep.Findings[0].Level >= harden.Warn {
top = hardenIcon(x.rep.Findings[0].Level) + " " + x.rep.Findings[0].Title
}
lines = append(lines, fmt.Sprintf("%-22s %4d %5d %s", name, b, w, trunc(top, 70)))
fmt.Fprintf(&md, "| %s | %d | %d | %s |\n", x.conn.Alias, b, w, top)
}
}
lines = append(lines, "", i18n.T("Einzelheiten mit Vorschlägen: Tab des Hosts öffnen, F6 › h."))
}
lines = append(lines, "", i18n.T("Nur lesend. sshTermy ändert nichts; die Vorschläge setzt du selbst um."))
scroll := 0
if a.modal != nil && a.modal.kind == mText && a.modal.harden {
scroll = a.modal.scroll
}
a.modal = textModal(title, lines)
a.modal.copy, a.modal.scroll, a.modal.harden = md.String(), scroll, true
}
func hardenRank(x hardenHost) int {
if x.rep == nil {
return -1
}
b, w, _ := x.rep.Counts()
return b*100 + w
}
// viewHardenRow: Zeile „Härtung“ in F6.
func (a *App) viewHardenRow(b *strings.Builder, s *session, w int) {
st := a.s
label := st.Muted.Render(fmt.Sprintf("%-9s ", i18n.T("Härtung")))
r := a.storedHarden(s.conn.ID)
if r == nil {
b.WriteString(label + st.Muted.Render(trunc(i18n.T("nicht geprüft · h prüft (nur lesend)"), w-10)) + "\n")
return
}
bad, warn, _ := r.Counts()
style := st.OK
switch {
case bad > 0:
style = st.Danger
case warn > 0:
style = st.Warn
}
b.WriteString(label + style.Render(trunc(hardenCountText(r), w-22)) + st.Muted.Render(" · "+ago(r.At)) + "\n")
}
+174
View File
@@ -0,0 +1,174 @@
package ui
import (
"context"
"crypto/ed25519"
"crypto/rand"
pemlib "encoding/pem"
"errors"
"os"
"path/filepath"
"strings"
"testing"
"time"
"golang.org/x/crypto/ssh"
"github.com/db9979/sshtermy/internal/domain"
"github.com/db9979/sshtermy/internal/keyinv"
)
func pumpEvents(t *testing.T, a *App, cond func() bool) {
t.Helper()
deadline := time.After(5 * time.Second)
for !cond() {
select {
case m := <-a.events:
a.Update(m)
case <-deadline:
t.Fatal("keine Antwort")
}
}
}
func TestHardenFolder(t *testing.T) {
a := vulnTestApp(t)
for _, n := range []string{"db01", "web01", "kaputt"} {
if _, err := a.st.UpsertConnection(domain.Connection{Alias: n, Host: n, Username: "root", Group: "Prod"}); err != nil {
t.Fatal(err)
}
}
old := hardenRunHost
defer func() { hardenRunHost = old }()
hardenRunHost = func(*App) func(context.Context, domain.Connection, string) (string, error) {
return func(_ context.Context, c domain.Connection, _ string) (string, error) {
switch c.Alias {
case "kaputt":
return "", errors.New("Verbindung abgelehnt")
case "db01":
return "root=1\nsshd=permitrootlogin yes\nsshd=passwordauthentication yes\nlis=0.0.0.0:6379|\nlis=0.0.0.0:22|\n", nil
}
return "root=1\nsshd=permitrootlogin no\nsshd=passwordauthentication no\nfw=ufw Status: active\nauto=unit dnf-automatic.timer\n", nil
}
}
a.openHardenFolder()
a.pickerChoose(pickItem{value: "Prod"})
pumpEvents(t, a, func() bool { return !a.hard.busy })
txt := strings.Join(a.modal.lines, "\n")
if !a.modal.harden || !strings.Contains(txt, "× Verbindung abgelehnt") {
t.Fatalf("%s", txt)
}
if i, j := strings.Index(txt, "db01"), strings.Index(txt, "web01"); i < 0 || i > j {
t.Fatalf("db01 (rot) nicht oben:\n%s", txt)
}
var db domain.Connection
for _, c := range a.st.Connections() {
if c.Alias == "db01" {
db = c
}
}
r := a.storedHarden(db.ID)
if b, _, _ := r.Counts(); b < 2 {
t.Fatalf("nicht gespeichert: %+v", r)
}
if len(a.st.VulnReports()) != 0 {
t.Fatal("Härtung im Sicherheitscheck")
}
}
func authLine(t *testing.T, comment string) (string, string) {
t.Helper()
p, priv, _ := ed25519.GenerateKey(rand.Reader)
pk, _ := ssh.NewPublicKey(p)
_ = priv
return strings.TrimSpace(string(ssh.MarshalAuthorizedKey(pk))) + " " + comment, ssh.FingerprintSHA256(pk)
}
func TestKeyInventoryAndRemove(t *testing.T) {
a := vulnTestApp(t)
t.Setenv("HOME", t.TempDir())
// eigener Schlüssel einer Verbindung: wird nie entfernt
ownPub, priv, _ := ed25519.GenerateKey(rand.Reader)
pem, _ := ssh.MarshalPrivateKey(priv, "")
ownPK, _ := ssh.NewPublicKey(ownPub)
ownLine := strings.TrimSpace(string(ssh.MarshalAuthorizedKey(ownPK))) + " sshtermy"
keyFile := filepath.Join(t.TempDir(), "id_ed25519")
_ = os.WriteFile(keyFile, pemlib.EncodeToMemory(pem), 0o600)
for _, n := range []string{"web01", "web02"} {
c := domain.Connection{Alias: n, Host: n, Username: "admin", Group: "Web"}
if n == "web02" {
c.Auth, c.KeyPath = domain.AuthKeyFile, keyFile
}
if _, err := a.st.UpsertConnection(c); err != nil {
t.Fatal(err)
}
}
bob, bobFP := authLine(t, "bob@alt")
old, oldRm := keyinvRun, keyinvRemove
defer func() { keyinvRun, keyinvRemove = old, oldRm }()
keyinvRun = func(*App) func(context.Context, domain.Connection, string) (string, error) {
return func(_ context.Context, c domain.Connection, _ string) (string, error) {
out := "root=1\nkey=admin|/home/admin/.ssh/authorized_keys|" + bob + "\n"
if c.Alias == "web02" {
out += "key=admin|/home/admin/.ssh/authorized_keys|" + ownLine + "\n"
}
return out, nil
}
}
var removed []string
keyinvRemove = func(*App) func(context.Context, domain.Connection, []keyinv.Place, string) (int, error) {
return func(_ context.Context, c domain.Connection, ps []keyinv.Place, blob string) (int, error) {
removed = append(removed, c.Alias)
return len(ps), nil
}
}
a.openKeyinvFolder()
a.pickerChoose(pickItem{value: "Web"})
pumpEvents(t, a, func() bool { return !a.kinv.busy && len(a.kinv.keys) > 0 })
if a.pick == nil || len(a.pick.items) != 2 {
t.Fatalf("Liste: %+v", a.pick)
}
if a.pick.items[0].value != bobFP || !strings.Contains(a.pick.items[0].hint, "2 Hosts") {
t.Fatalf("bob nicht oben: %+v", a.pick.items)
}
// eigener Schlüssel: Entfernen verweigert
a.pickerChoose(a.pick.items[1])
a.Update(keyMsg("d"))
if a.modal == nil || a.modal.kind == mConfirm {
t.Fatal("eigener Anmeldeschlüssel ließe sich entfernen")
}
// bob von beiden Hosts, web02 auslassen
a.Update(keyMsg("left"))
a.pickerChoose(a.pick.items[0])
a.Update(keyMsg("d"))
if a.modal == nil || a.modal.kind != mConfirm {
t.Fatal("keine Bestätigung")
}
a.Update(keyMsg("j"))
a.Update(keyMsg("j"))
first := ""
for _, n := range []string{"web01", "web02"} {
if a.modal != nil && strings.Contains(a.modal.title, n) {
first = n
}
}
if first == "" {
t.Fatalf("Host-Bestätigung fehlt: %q", a.modal.title)
}
_, cmd := a.Update(keyMsg("j"))
if cmd != nil {
a.Update(cmd())
}
if a.modal == nil || a.modal.kind != mConfirm || strings.Contains(a.modal.title, first) {
t.Fatalf("zweiter Host: %q", a.modal.title)
}
a.Update(keyMsg("n"))
if strings.Join(removed, ",") != first {
t.Fatalf("entfernt: %v", removed)
}
k, _ := a.keyinvFind(bobFP)
if k.Hosts() != 1 {
t.Fatalf("Inventar nicht nachgeführt: %+v", k)
}
}
+7 -1
View File
@@ -208,6 +208,7 @@ var helpSections = []helpSection{
{"c", "Container (Docker, Podman, k8s)"},
{"l", "Log-Blick"},
{"s", "Sicherheitscheck · Switch: Firmware"},
{"h / a", "Härtungs-Check / Schlüssel-Inventar"},
{"↑ ↓", "Sicherung wählen"},
{"d", "Diff zur Vorversion"},
{"v", "Sicherung ansehen"},
@@ -268,6 +269,11 @@ var helpSections = []helpSection{
{"o", "alle Server im Ordner prüfen"},
{"r / c", "neu prüfen / kopieren"},
}},
{hcVuln, "■", "Schlüssel-Inventar", "F6 a", false, [][2]string{
{"⏎", "wo steht der Schlüssel?"},
{"d", "entfernen (je Host j, mit Kopie)"},
{"←", "zurück zur Liste"},
}},
{hcVuln, "■", "Patch-Runde", "Palette", false, [][2]string{
{"j j", "starten (Ordner, erster Host)"},
{"w", "nach Prüfung weiter"},
@@ -495,7 +501,7 @@ var helpTabs = []helpTabDef{
{"Terminal", []string{"Terminal", "Suche im Verlauf", "Tunnel", "Host-Übersicht", "Dateien", "Gefahren & Aufnahme", "Systemprofil"}},
{"KI", []string{"Ziel-Modus", "KI fragen", "KI-Begleiter", "Vorgang über mehrere Fenster", "KI-Einstellungen"}},
{"Manager", []string{"Verbindungs-Manager", "Broadcast", "Netzwerk-Scan"}},
{"Logs", []string{"Log-Blick", "Sicherheitscheck", "Patch-Runde", "Sitzungsprotokolle"}},
{"Logs", []string{"Log-Blick", "Sicherheitscheck", "Schlüssel-Inventar", "Patch-Runde", "Sitzungsprotokolle"}},
{"Überall", []string{"Überall", "Befehlspalette", "Aussehen & Tasten", "Maus"}},
}
+10 -1
View File
@@ -636,6 +636,14 @@ func (a *App) hostKey(s *session, k tea.KeyPressMsg) tea.Cmd {
return a.openFirmware(s)
}
return a.openVuln(s)
case "h":
if !net {
return a.openHarden(s)
}
case "a":
if !net {
return a.openKeyinvHost(s)
}
case "b":
if net && !h.busy {
s.panelFocus = false
@@ -729,7 +737,7 @@ func (a *App) hostPanelKeys(s *session) [][2]string {
}
k = append(k, [2]string{"t", span}, [2]string{"z", size})
}
return append(k, [2]string{"l", "Logs"}, [2]string{"s", i18n.T("Sicherheit")}, [2]string{"c", i18n.T("Container")}, [2]string{"g", i18n.T("Grenzwerte")}, [2]string{"Esc", "Terminal"}, [2]string{a.keys.label(actHost), i18n.T("schließen")})
return append(k, [2]string{"l", "Logs"}, [2]string{"s", i18n.T("Sicherheit")}, [2]string{"h", i18n.T("Härtung")}, [2]string{"a", i18n.T("Schlüssel")}, [2]string{"c", i18n.T("Container")}, [2]string{"g", i18n.T("Grenzwerte")}, [2]string{"Esc", "Terminal"}, [2]string{a.keys.label(actHost), i18n.T("schließen")})
}
// ---------------------------------------------------------------- Ansicht
@@ -853,6 +861,7 @@ func (a *App) viewHost(b *strings.Builder, s *session, w int) {
b.WriteString(st.Warn.Render(i18n.T("◌ Neustart erforderlich")) + "\n")
}
a.viewVulnRow(b, s, w)
a.viewHardenRow(b, s, w)
for _, e := range srv.Extras {
row(trunc(e.Label, 9), e.Value)
}
+503
View File
@@ -0,0 +1,503 @@
package ui
import (
"context"
"errors"
"fmt"
"os"
"path/filepath"
"strings"
"time"
tea "charm.land/bubbletea/v2"
"golang.org/x/crypto/ssh"
"github.com/db9979/sshtermy/internal/audit"
"github.com/db9979/sshtermy/internal/domain"
"github.com/db9979/sshtermy/internal/i18n"
"github.com/db9979/sshtermy/internal/keyinv"
"github.com/db9979/sshtermy/internal/sshx"
)
// Schlüssel-Inventar (F6 a, Palette „Schlüssel-Inventar“): welche
// öffentlichen Schlüssel stehen in welchen authorized_keys? Lesen ist nur
// lesend. Entfernen fragt je Host, legt eine Sicherungskopie an und
// verweigert den Schlüssel, mit dem sshTermy sich selbst dort anmeldet.
type keyinvHost struct {
conn domain.Connection
host *keyinv.Host
err string
done bool
}
type keyinvState struct {
seq int
busy bool
title string
hosts []keyinvHost
keys []keyinv.Key
sel string // gewählter Fingerabdruck
cancel context.CancelFunc
// Entfernen: Warteschlange je Host
rmKey keyinv.Key
rmQueue []string // Verbindungs-IDs
rmDone []string
}
type keyinvMsg struct {
seq int
i int
host *keyinv.Host
err error
}
type keyinvRmMsg struct {
id string
removed int
err error
}
// keyinvRun: Skript auf einem Host (in Tests austauschbar).
var keyinvRun = func(a *App) func(ctx context.Context, c domain.Connection, script string) (string, error) {
return a.quietScript
}
// keyinvRemove: Schlüssel auf einem Host entfernen (in Tests austauschbar).
var keyinvRemove = func(a *App) func(ctx context.Context, c domain.Connection, places []keyinv.Place, blob string) (int, error) {
dial := patchDial(a)
return func(ctx context.Context, c domain.Connection, places []keyinv.Place, blob string) (int, error) {
cl, err := dial(ctx, c)
if err != nil {
return 0, err
}
defer cl.Close()
stamp := time.Now().Format("20060102-150405")
total := 0
for _, p := range places {
script := keyinv.RemoveScript(p.File, blob, stamp)
cmd := "sh -c " + sshx.Quote(script)
var in []byte
if p.User != c.Username && c.Username != "root" {
cmd = "LC_ALL=C sudo -n sh -c " + sshx.Quote(script)
if res, err := cl.ExecInput(ctx, "LC_ALL=C sudo -n true", nil); err != nil || res.Exit != 0 {
pw := ""
for _, cand := range []string{c.Password.Reveal(), keychainIf(c, sshx.SecretSudo), keychainIf(c, sshx.SecretPassword)} {
if cand == "" {
continue
}
if r, err := cl.ExecInput(ctx, "LC_ALL=C sudo -S -p '' true", []byte(cand+"\n")); err == nil && r.Exit == 0 {
pw = cand
break
}
}
if pw == "" {
return total, errors.New(i18n.T("fremde authorized_keys brauchen sudo; kein passendes Passwort gespeichert"))
}
cmd, in = "LC_ALL=C sudo -S -p '' sh -c "+sshx.Quote(script), []byte(pw+"\n")
}
}
res, err := cl.ExecInput(ctx, cmd, in)
if err != nil {
return total, err
}
out := string(res.Output)
if i := strings.Index(out, "removed="); i >= 0 {
var n int
fmt.Sscanf(out[i+8:], "%d", &n)
total += n
} else if res.Exit != 0 {
return total, fmt.Errorf("%s: %s", p.File, strings.TrimSpace(lastLine(out)))
}
}
return total, nil
}
}
func keychainIf(c domain.Connection, kind string) string {
if !c.Keychain {
return ""
}
return sshx.KeychainSecret(c.ID, kind)
}
// ownKeys: Fingerabdrücke der Schlüssel dieses Rechners (~/.ssh/*.pub und
// die Schlüssel der Verbindungen) → Name.
func (a *App) ownKeys() (names map[string]string, byConn map[string]string) {
names, byConn = map[string]string{}, map[string]string{}
home, _ := os.UserHomeDir()
if home != "" {
pubs, _ := filepath.Glob(filepath.Join(home, ".ssh", "*.pub"))
for _, p := range pubs {
if b, err := os.ReadFile(p); err == nil {
if pk, _, _, _, err := ssh.ParseAuthorizedKey(b); err == nil {
names[ssh.FingerprintSHA256(pk)] = i18n.T("dieser Rechner: ") + filepath.Base(p)
}
}
}
}
for _, c := range a.st.Connections() {
if fp := connKeyFP(c, home); fp != "" {
byConn[c.ID] = fp
if _, ok := names[fp]; !ok {
names[fp] = i18n.T("Schlüssel der Verbindung ") + c.Alias
}
}
}
return names, byConn
}
// connKeyFP: Fingerabdruck des Schlüssels, mit dem sich die Verbindung
// anmeldet ("" = keiner/unbekannt).
func connKeyFP(c domain.Connection, home string) string {
if c.Auth != domain.AuthKeyFile {
return ""
}
if c.KeyPEM.IsSet() {
if s, err := ssh.ParsePrivateKey([]byte(c.KeyPEM.Reveal())); err == nil {
return ssh.FingerprintSHA256(s.PublicKey())
}
return ""
}
for _, p := range domain.KeyPathCandidates(c.KeyPath, home) {
if b, err := os.ReadFile(p + ".pub"); err == nil {
if pk, _, _, _, err := ssh.ParseAuthorizedKey(b); err == nil {
return ssh.FingerprintSHA256(pk)
}
}
if b, err := os.ReadFile(p); err == nil {
if s, err := ssh.ParsePrivateKey(b); err == nil {
return ssh.FingerprintSHA256(s.PublicKey())
}
}
}
return ""
}
// openKeyinvHost: F6 a, nur dieser Host.
func (a *App) openKeyinvHost(s *session) tea.Cmd {
if s == nil || s.netDevice() || s.isWinRM() || s.prof.Family == domain.FamilyWindows || s.conn.Protocol != domain.ProtoSSH && s.conn.Protocol != "" {
if s != nil {
s.host.err = i18n.T("Schlüssel-Inventar geht nur bei Servern über SSH")
}
return nil
}
return a.runKeyinv(s.conn.Alias, []domain.Connection{s.conn})
}
func (a *App) openKeyinvFolder() tea.Cmd {
return a.folderPicker(i18n.T("Schlüssel-Inventar: Ordner wählen"), vulnScanable,
i18n.T("Liest die authorized_keys aller Benutzer (mit sudo ohne Passwort, sonst nur die eigenen), nur lesend, ohne Rückfragen."),
func(folder string) tea.Cmd {
where := folder
if where == "" {
where = i18n.T("alle Verbindungen")
}
return a.runKeyinv(where, a.vulnFolderConns(folder))
})
}
func (a *App) runKeyinv(title string, conns []domain.Connection) tea.Cmd {
if len(conns) == 0 {
a.flash(i18n.T("Keine Linux-Server (SSH) im Ordner"))
return nil
}
k := &a.kinv
if k.cancel != nil {
k.cancel()
}
ctx, cancel := context.WithTimeout(context.Background(), 20*time.Minute)
*k = keyinvState{seq: k.seq + 1, busy: true, title: title, cancel: cancel}
for _, c := range conns {
k.hosts = append(k.hosts, keyinvHost{conn: c})
}
seq, ev, run := k.seq, a.events, keyinvRun(a)
go func() {
defer cancel()
forHosts(ctx, conns, 4, func(ctx context.Context, i int, c domain.Connection) {
if ctx.Err() != nil {
ev <- keyinvMsg{seq: seq, i: i, err: ctx.Err()}
return
}
out, err := run(ctx, c, keyinv.Script)
if err != nil {
ev <- keyinvMsg{seq: seq, i: i, err: err}
return
}
h := keyinv.Parse(out)
ev <- keyinvMsg{seq: seq, i: i, host: &h}
})
}()
a.flash(fmt.Sprintf(i18n.T("Schlüssel-Inventar: lese %d Hosts …"), len(conns)))
return nil
}
func (a *App) keyinvMsgs(msg tea.Msg) (tea.Cmd, bool) {
switch m := msg.(type) {
case keyinvMsg:
k := &a.kinv
if m.seq != k.seq || m.i >= len(k.hosts) {
return a.listen(), true
}
x := &k.hosts[m.i]
x.done, x.host = true, m.host
if m.err != nil {
x.err = m.err.Error()
}
k.busy = false
for _, y := range k.hosts {
if !y.done {
k.busy = true
}
}
if !k.busy {
a.keyinvMerge()
a.showKeyinvList()
}
return a.listen(), true
case keyinvRmMsg:
a.keyinvRmDone(m)
return nil, true
}
return nil, false
}
func (a *App) keyinvMerge() {
k := &a.kinv
hosts, names := map[string]keyinv.Host{}, map[string]string{}
for _, x := range k.hosts {
if x.host != nil {
hosts[x.conn.ID] = *x.host
names[x.conn.ID] = x.conn.Alias
}
}
own, _ := a.ownKeys()
k.keys = keyinv.Merge(hosts, names, own)
}
// showKeyinvList: Schlüssel als Auswahlliste (Suche nach Name, Host, Typ).
func (a *App) showKeyinvList() {
k := &a.kinv
if len(k.hosts) == 0 {
a.flash(i18n.T("Noch kein Schlüssel-Inventar gelesen"))
return
}
var items []pickItem
for _, key := range k.keys {
label := key.Label()
if label == "" {
label = i18n.T("(ohne Namen)")
}
hint := fmt.Sprintf(i18n.T("%d Hosts"), key.Hosts())
if w := key.Weak(); w != "" {
hint = "▲ " + w + " · " + hint
}
var hs []string
for _, p := range key.Places {
hs = append(hs, p.Host+" "+p.User)
}
items = append(items, pickItem{value: key.FP, label: trunc(label, 40) + " " + shortType(key.Type), hint: hint, search: strings.Join(hs, " ") + " " + key.FP})
}
okN, errN, notRoot := 0, 0, 0
for _, x := range k.hosts {
switch {
case x.host != nil:
okN++
if !x.host.Root {
notRoot++
}
case x.err != "":
errN++
}
}
a.pick = newPicker(i18n.T("Schlüssel-Inventar: ")+k.title, i18n.T("Name, Host oder Benutzer suchen …"), items, k.sel, func(it pickItem) tea.Cmd {
k.sel = it.value
a.showKeyinvKey(it.value)
return nil
})
help := fmt.Sprintf(i18n.T("%d Schlüssel auf %d Hosts gelesen"), len(k.keys), okN)
if errN > 0 {
help += fmt.Sprintf(i18n.T(", %d nicht erreichbar"), errN)
}
if notRoot > 0 {
help += fmt.Sprintf(i18n.T(", %d nur eigener Benutzer (ohne sudo)"), notRoot)
}
a.pick.help = help + ". " + i18n.T("⏎ zeigt, wo ein Schlüssel steht; dort entfernt d ihn.")
}
func shortType(t string) string {
t = strings.TrimPrefix(t, "ssh-")
t = strings.TrimPrefix(t, "sk-")
return strings.Split(t, "@")[0]
}
func (a *App) keyinvFind(fp string) (keyinv.Key, bool) {
for _, k := range a.kinv.keys {
if k.FP == fp {
return k, true
}
}
return keyinv.Key{}, false
}
// showKeyinvKey: wo steht der Schlüssel? d entfernt.
func (a *App) showKeyinvKey(fp string) {
key, ok := a.keyinvFind(fp)
if !ok {
return
}
var lines []string
var md strings.Builder
label := orDefault(key.Label(), i18n.T("(ohne Namen)"))
lines = append(lines, fmt.Sprintf("%s · %s %d Bit", label, key.Type, key.Bits), key.FP)
fmt.Fprintf(&md, "# %s\n\n%s %d Bit · %s\n\n", label, key.Type, key.Bits, key.FP)
if w := key.Weak(); w != "" {
lines = append(lines, "▲ "+fmt.Sprintf(i18n.T("Veraltet (%s): durch einen ed25519-Schlüssel ersetzen."), w))
}
if key.Own != "" {
lines = append(lines, "i "+i18n.T("Eigener Schlüssel dieses Rechners."))
}
lines = append(lines, "", fmt.Sprintf(i18n.T("Steht auf %d Hosts:"), key.Hosts()))
md.WriteString(i18n.T("| Host | Benutzer | Datei |\n|---|---|---|\n"))
for _, p := range key.Places {
lines = append(lines, fmt.Sprintf(" %-22s %-12s %s", trunc(p.Host, 22), trunc(p.User, 12), p.File))
fmt.Fprintf(&md, "| %s | %s | %s |\n", p.Host, p.User, p.File)
}
lines = append(lines, "", i18n.T("d = von allen diesen Hosts entfernen (fragt je Host, mit Sicherungskopie) · ← zurück zur Liste · c kopieren"))
a.modal = textModal(i18n.T("Schlüssel"), lines)
a.modal.copy, a.modal.keyinv = md.String(), true
}
func (a *App) keyinvKey(key string) (tea.Cmd, bool) {
k := &a.kinv
switch key {
case "left", "backspace":
if len(k.rmQueue) == 0 {
a.modal = nil
a.showKeyinvList()
return nil, true
}
case "d":
kk, ok := a.keyinvFind(k.sel)
if !ok {
return nil, true
}
if !keyinv.ValidBlob(kk.Blob) {
a.flashErr(i18n.T("Schlüssel lässt sich nicht sicher entfernen"))
return nil, true
}
_, byConn := a.ownKeys()
seen := map[string]bool{}
var ids []string
blocked := 0
for _, p := range kk.Places {
if seen[p.ID] {
continue
}
seen[p.ID] = true
if byConn[p.ID] == kk.FP {
blocked++
continue
}
ids = append(ids, p.ID)
}
if len(ids) == 0 {
a.flashErr(i18n.T("Darüber meldet sich sshTermy selbst an, nicht entfernt"))
return nil, true
}
body := fmt.Sprintf(i18n.T("„%s“ aus den authorized_keys von %d Hosts entfernen? Du bestätigst danach jeden Host einzeln. Vorher wird je Datei eine Kopie <datei>.sshtermy-<Zeit> angelegt."), orDefault(kk.Label(), kk.FP), len(ids))
if blocked > 0 {
body += "\n\n" + fmt.Sprintf(i18n.T("%d Hosts bleiben unverändert: sshTermy meldet sich dort mit genau diesem Schlüssel an."), blocked)
}
body += "\n\n" + i18n.T("j = weiter · n = abbrechen")
m := confirmModal(i18n.T("Schlüssel entfernen?"), body, func() tea.Cmd {
k.rmKey, k.rmQueue, k.rmDone = kk, ids, nil
return a.keyinvAskNext()
})
m.twice = true
a.modal = m
return nil, true
}
return nil, false
}
// keyinvAskNext: nächsten Host bestätigen lassen.
func (a *App) keyinvAskNext() tea.Cmd {
k := &a.kinv
if len(k.rmQueue) == 0 {
if len(k.rmDone) > 0 {
a.flashOK(fmt.Sprintf(i18n.T("Schlüssel entfernt auf: %s"), strings.Join(k.rmDone, ", ")))
}
a.keyinvMerge()
a.showKeyinvKey(k.rmKey.FP)
if _, ok := a.keyinvFind(k.rmKey.FP); !ok {
a.modal = nil
a.showKeyinvList()
}
return nil
}
id := k.rmQueue[0]
c, ok := a.st.Connection(id)
if !ok {
k.rmQueue = k.rmQueue[1:]
return a.keyinvAskNext()
}
var files []string
for _, p := range k.rmKey.Places {
if p.ID == id {
files = append(files, p.User+": "+p.File)
}
}
body := fmt.Sprintf(i18n.T("%s (%s)\n%s\n\nj = entfernen · n = diesen Host auslassen"), c.Alias, c.Host, strings.Join(files, "\n"))
m := confirmModal(fmt.Sprintf(i18n.T("Schlüssel auf %s entfernen?"), c.Alias), body, func() tea.Cmd {
var places []keyinv.Place
for _, p := range k.rmKey.Places {
if p.ID == id {
places = append(places, p)
}
}
rm := keyinvRemove(a)
blob := k.rmKey.Blob
a.audit.Add(audit.EvConfig, c.Alias, "authorized_keys: "+k.rmKey.FP+" entfernt")
a.flash(fmt.Sprintf(i18n.T("entferne auf %s …"), c.Alias))
return func() tea.Msg {
ctx, cancel := context.WithTimeout(context.Background(), 2*time.Minute)
defer cancel()
n, err := rm(ctx, c, places, blob)
return keyinvRmMsg{id: id, removed: n, err: err}
}
})
m.onCancel = func() tea.Cmd {
k.rmQueue = k.rmQueue[1:]
return a.keyinvAskNext()
}
a.modal = m
return nil
}
func (a *App) keyinvRmDone(m keyinvRmMsg) {
k := &a.kinv
if len(k.rmQueue) > 0 && k.rmQueue[0] == m.id {
k.rmQueue = k.rmQueue[1:]
}
c, _ := a.st.Connection(m.id)
if m.err != nil {
a.flashErr(c.Alias + ": " + m.err.Error())
} else if m.removed > 0 {
k.rmDone = append(k.rmDone, c.Alias)
// Inventar nachführen
for i := range k.hosts {
if k.hosts[i].conn.ID != m.id || k.hosts[i].host == nil {
continue
}
var keep []keyinv.Entry
for _, e := range k.hosts[i].host.Entries {
if e.FP != k.rmKey.FP {
keep = append(keep, e)
}
}
k.hosts[i].host.Entries = keep
}
}
a.keyinvAskNext()
}
+1 -1
View File
@@ -241,7 +241,7 @@ func (a *App) folderScanMsg(msg tea.Msg) (tea.Cmd, bool) {
if f.allDone() {
a.flashOK(fmt.Sprintf(i18n.T("Ordner-Scan fertig: %d Hosts in %s"), len(f.hosts), durText(time.Since(f.start))))
}
if f.open && a.modal != nil && a.modal.kind == mText && a.modal.copy != "" && !a.modal.vuln && !a.modal.fw && !a.modal.patch {
if f.open && a.modal != nil && a.modal.kind == mText && a.modal.copy != "" && !a.modal.vuln && !a.modal.fw && !a.modal.patch && !a.modal.harden && !a.modal.keyinv {
a.showFolderScan()
}
return a.listen(), true
+7
View File
@@ -45,6 +45,8 @@ type modal struct {
vuln bool // mText: Ergebnis des Sicherheitschecks über einen Ordner (vulnfolder.go)
fw bool // mText: Firmware-Hinweise (firmware.go)
patch bool // mText: Patch-Runde (patchround.go)
harden bool // mText: Härtungs-Check (harden.go)
keyinv bool // mText: Schlüssel-Inventar, ein Schlüssel (keyinv.go)
mail string // mText: m öffnet diese mailto:-Adresse im Mailprogramm
title string
body string
@@ -289,6 +291,11 @@ func (a *App) modalKey(k tea.KeyPressMsg) tea.Cmd {
return cmd
}
}
if m.keyinv {
if cmd, ok := a.keyinvKey(key); ok {
return cmd
}
}
if m.textKey(key) {
a.modal = nil
}
+16
View File
@@ -424,6 +424,18 @@ func (a *App) palActsGlobal(add palAdd, inMgr bool) {
add("net", palItem{icon: ic("lock"), label: i18n.T("Firmware-Hinweise: letztes Ergebnis"), hint: trunc(a.fwchk.title, 18),
keys: "firmware sicherheit nvd ergebnis", run: func() tea.Cmd { a.showFirmware(); return nil }})
}
add("net", palItem{icon: ic("lock"), label: i18n.T("Härtungs-Check: alle Server im Ordner …"), hint: i18n.T("nur lesend"),
keys: "härtung hardening sicherheit security sshd firewall ports zertifikat ordner folder", run: func() tea.Cmd { return a.openHardenFolder() }})
if len(a.hard.hosts) > 0 {
add("net", palItem{icon: ic("lock"), label: i18n.T("Härtungs-Check: letztes Ergebnis"), hint: trunc(a.hard.title, 18),
keys: "härtung hardening ergebnis", run: func() tea.Cmd { a.showHarden(); return nil }})
}
add("net", palItem{icon: ic("sshkey"), label: i18n.T("Schlüssel-Inventar: authorized_keys im Ordner …"), hint: i18n.T("wer hat Zugang?"),
keys: "schlüssel keys authorized_keys inventar zugang access kollege ausgeschieden entfernen ordner folder", run: func() tea.Cmd { return a.openKeyinvFolder() }})
if len(a.kinv.keys) > 0 {
add("net", palItem{icon: ic("sshkey"), label: i18n.T("Schlüssel-Inventar: letztes Ergebnis"), hint: trunc(a.kinv.title, 18),
keys: "schlüssel inventar ergebnis keys", run: func() tea.Cmd { a.showKeyinvList(); return nil }})
}
add("net", palItem{icon: ic("restart"), label: i18n.T("Patch-Runde: Updates gestaffelt über einen Ordner …"), hint: i18n.T("erst ein Host"),
keys: "patch runde updates upgrade aktualisieren ordner gestaffelt kanarienvogel canary rollout apt dnf neustart reboot", run: func() tea.Cmd { return a.openPatch() }})
if len(a.patch.hosts) > 0 {
@@ -497,6 +509,10 @@ func (a *App) palActsTerminal(add palAdd, s *session, inTerm bool) {
if a.vulnOK(s) == nil {
add("session", palItem{icon: ic("lock"), label: i18n.T("Sicherheitscheck: Pakete gegen bekannte Lücken (OSV)"), hint: i18n.T("F6 s"),
keys: "sicherheit security osv cve schwachstellen vulnerabilities lücken pakete packages kev patch update", run: func() tea.Cmd { return a.openVuln(s) }})
add("session", palItem{icon: ic("lock"), label: i18n.T("Härtungs-Check: sshd, Firewall, Ports, Zertifikate"), hint: i18n.T("F6 h"),
keys: "härtung hardening sicherheit security sshd root passwort firewall ports zertifikat cert tls sudo audit cis", run: func() tea.Cmd { return a.openHarden(s) }})
add("session", palItem{icon: ic("sshkey"), label: i18n.T("Schlüssel-Inventar: authorized_keys dieses Hosts"), hint: i18n.T("F6 a"),
keys: "schlüssel keys authorized_keys inventar zugang access ssh key kollege entfernen", run: func() tea.Cmd { return a.openKeyinvHost(s) }})
}
if a.containersOK(s) {
add("session", palItem{icon: ic("host"), label: i18n.T("Container (Docker, Podman, Kubernetes)"), hint: i18n.T("F6 c"),
+1 -1
View File
@@ -20,7 +20,7 @@
│ ── ALLE AKTIONEN ─────────────────────────────────────────────────────── │
│ [/] Suchen & Logs › Verlauf, alle Tabs, Log-Blick, Protokolle 3 │
│ [T] Tabs & Ansicht › neu, teilen, Zoom, Arbeitsplätze 2 │
│ [*] Mehrere Hosts & Netzwerk › Broadcast, Scan, Zeitpläne, Switches 8 │
│ [*] Mehrere Hosts & Netzwerk › Broadcast, Scan, Zeitpläne, Switch… 10 │
│ [&] Team & Teilen › live teilen, Team-Ordner 4 │
│ [=] Verbindungen & Daten › neu, SSH-Key, Import/Export, Sicherung 6 │
│ │
+1 -1
View File
@@ -20,7 +20,7 @@
│ ── ALL ACTIONS ───────────────────────────────────────────────────────── │
│ [/] Search & logs › scrollback, all tabs, log glance, session logs 3 │
│ [T] Tabs & view › new, split, zoom, workspaces 2 │
│ [*] Several hosts & network › broadcast, scan, schedules, switches 8 │
│ [*] Several hosts & network › broadcast, scan, schedules, switches 10 │
│ [&] Team & sharing › live sharing, team folders 4 │
│ [=] Connections & data › new, SSH key, import/export, backup 6 │
│ │
+9 -9
View File
@@ -17,15 +17,15 @@
┃│ ⇧F10 Tab in eigenes Fenster (Sitzung bleibt c Container (Docker, Podman, k8s) │┃
┃│ offen) l Log-Blick │┃
┃│ Tab / → Ghost-Text übernehmen s Sicherheitscheck · Switch: Firmware │┃
┃│ Alt+1…4 Folgebefehl einfügen ↑ ↓ Sicherung wählen │┃
┃│ Alt+0 Fehler: Warum? & Fix d Diff zur Vorversion │┃
┃│ Alt+K KI-Begleiter: Aus/Leise/Gesprächig/Coach v Sicherung ansehen │┃
┃│ Alt+J Begleiter-Leiste g Grenzwerte für Warnungen │┃
┃│ Alt+V Vorgang über mehrere Fenster (KI sieht t Graphen: 5 min / 1 h │┃
┃│ alle) z Graphen groß │┃
┃│ Strg+T Aufteilung wählen (1…7) x Abfrage abbrechen │┃
┃│ Strg+Pfeil Bereich wechseln (geteilt) │┃
┃│ Alt+⇧Pfeil Trennlinie verschieben (Maus: ziehen) ▤ Dateien F5 │┃
┃│ Alt+1…4 Folgebefehl einfügen h / a Härtungs-Check / Schlüssel-Inventar │┃
┃│ Alt+0 Fehler: Warum? & Fix ↑ ↓ Sicherung wählen │┃
┃│ Alt+K KI-Begleiter: Aus/Leise/Gesprächig/Coach d Diff zur Vorversion │┃
┃│ Alt+J Begleiter-Leiste v Sicherung ansehen │┃
┃│ Alt+V Vorgang über mehrere Fenster (KI sieht g Grenzwerte für Warnungen │┃
┃│ alle) t Graphen: 5 min / 1 h │┃
┃│ Strg+T Aufteilung wählen (1…7) z Graphen groß │┃
┃│ Strg+Pfeil Bereich wechseln (geteilt) x Abfrage abbrechen │┃
┃│ Alt+⇧Pfeil Trennlinie verschieben (Maus: ziehen) │┃
┃│ │┃
┃│ ROT Gefährliche Befehle brauchen zweimal ⏎ bzw. Alt+N. KI-Vorschläge werden nur eingefügt, nie ausgeführt. │┃
┃│ Esc führt aus jedem Panel zurück ins Terminal. │┃
+17 -17
View File
@@ -9,23 +9,23 @@
┃│ F4 Tunnel c Containers (Docker, Podman, k8s) │┃
┃│ F5 Files (SFTP) l Log view │┃
┃│ F6 Host overview s security check · switch: firmware │┃
┃│ F7 / F8 switch tab ↑ ↓ choose backup │┃
┃│ F9 Quick commands (list) d diff to previous │┃
┃│ F9 → a adopt a frequent command v view backup │┃
┃│ F10 to manager g Warning limits │┃
┃│ ⇧F1…F8 run quick command t graphs: 5 min / 1 h │┃
┃│ ⇧F10 Tab to own window (session stays open) z graphs large │┃
┃│ Tab / → accept ghost text x cancel query │┃
┃│ Alt+1…4 insert follow-up command │┃
┃│ Alt+0 Error: Why? & Fix ▤ Files F5 │┃
┃│ Alt+K AI companion: off/quiet/chatty/coach F2 rename │┃
┃│ Alt+J Companion sidebar Tab switch side │┃
┃│ Alt+V Task across several windows (AI sees all) ⏎ / 2×click open, view file │┃
┃│ Ctrl+T choose layout (1…7) ← / Bksp one level up │┃
┃│ Ctrl+arrow switch pane (split) c / F6 copy (up/down) │┃
┃│ Alt+⇧arrow move divider (mouse: drag) e open in your own editor │┃
┃│ Alt+Z Zoom pane / back o with the default app │┃
┃│ Drag title swap panes Space / a mark / all │┃
┃│ F7 / F8 switch tab h / a hardening check / key inventory │┃
┃│ F9 Quick commands (list) ↑ ↓ choose backup │┃
┃│ F9 → a adopt a frequent command d diff to previous │┃
┃│ F10 to manager v view backup │┃
┃│ ⇧F1…F8 run quick command g Warning limits │┃
┃│ ⇧F10 Tab to own window (session stays open) t graphs: 5 min / 1 h │┃
┃│ Tab / → accept ghost text z graphs large │┃
┃│ Alt+1…4 insert follow-up command x cancel query │┃
┃│ Alt+0 Error: Why? & Fix │┃
┃│ Alt+K AI companion: off/quiet/chatty/coach ▤ Files F5 │┃
┃│ Alt+J Companion sidebar F2 rename │┃
┃│ Alt+V Task across several windows (AI sees all) Tab switch side │┃
┃│ Ctrl+T choose layout (1…7) ⏎ / 2×click open, view file │┃
┃│ Ctrl+arrow switch pane (split) ← / Bksp one level up │┃
┃│ Alt+⇧arrow move divider (mouse: drag) c / F6 copy (up/down) │┃
┃│ Alt+Z Zoom pane / back e open in your own editor │┃
┃│ Drag title swap panes o with the default app │┃
┃│ │┃
┃│ RED Dangerous commands need ⏎ twice or Alt+N. AI suggestions are only inserted, never run. │┃
┃│ Esc leads back to the terminal from every panel. │┃
+1 -1
View File
@@ -29,4 +29,4 @@
┃ └──────────────────────────────────────────────┘┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
r aktualisieren l Logs s Sicherheit c Container g Grenzwerte Esc Terminal F6 schließen
r aktualisieren l Logs s Sicherheit h Härtung a Schlüssel c Container g Grenzwerte Esc Terminal F6 schließen
+1 -1
View File
@@ -29,4 +29,4 @@
┃ └──────────────────────────────────────────────┘┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
r update l Logs s Security c Containers g Limits Esc Terminal F6 close
r update l Logs s Security h Hardening a Key c Containers g Limits Esc Terminal F6 close
+1 -1
View File
@@ -85,7 +85,7 @@
<li><kbd>⇧F10</kbd> verschiebt einen Tab in ein eigenes Terminalfenster.</li>
<li><kbd>Strg</kbd>+<kbd>F</kbd> durchsucht den Verlauf, <kbd>Strg</kbd>+<kbd>E</kbd> springt zu Fehlerzeilen. <kbd>Alt</kbd>+<kbd>S</kbd> sucht in allen offenen Tabs.</li>
<li><kbd>F9</kbd> und <kbd>⇧F1</kbd>…<kbd>⇧F8</kbd>: Schnellbefehle, passend zum Gerät vorbelegt (Linux, Windows, Aruba, Cisco, Juniper, MikroTik, FortiGate …).</li>
<li><kbd>F6</kbd> Host-Übersicht: CPU, RAM, Platte, Updates bei Servern, bei Linux Live-Graphen (<kbd>t</kbd> 5 min / 1 h, <kbd>z</kbd> groß); Firmware, Ports und VLANs bei Netzwerkgeräten; <kbd>c</kbd> Container; <kbd>s</kbd> Sicherheitscheck: installierte Pakete gegen die OSV-Datenbank (Bewertung, Reparatur vorhanden, aktiv ausgenutzt, von laufendem Dienst genutzt); an Switches und Firewalls Firmware-Hinweise aus der NVD. Palette <em>Patch-Runde</em>: Updates gestaffelt über einen Ordner, erst ein Host, dann <kbd>w</kbd> für den Rest.</li>
<li><kbd>F6</kbd> Host-Übersicht: CPU, RAM, Platte, Updates bei Servern, bei Linux Live-Graphen (<kbd>t</kbd> 5 min / 1 h, <kbd>z</kbd> groß); Firmware, Ports und VLANs bei Netzwerkgeräten; <kbd>c</kbd> Container; <kbd>s</kbd> Sicherheitscheck: installierte Pakete gegen die OSV-Datenbank (Bewertung, Reparatur vorhanden, aktiv ausgenutzt, von laufendem Dienst genutzt); an Switches und Firewalls Firmware-Hinweise aus der NVD. Palette <em>Patch-Runde</em>: Updates gestaffelt über einen Ordner, erst ein Host, dann <kbd>w</kbd> für den Rest. <kbd>h</kbd> Härtungs-Check (nur lesend), <kbd>a</kbd> Schlüssel-Inventar der <code>authorized_keys</code>.</li>
<li>Reißt die Leitung ab (WLAN, VPN, Ruhezustand), verbindet sshTermy von selbst neu, startet Tunnel und hängt tmux/screen wieder an. Nach dem Aufwachen oder einem Netzwechsel werden alle Leitungen sofort geprüft.</li>
</ul>
</section>
+2
View File
@@ -154,6 +154,7 @@ sudo apt update && sudo apt install sshtermy</pre></div>
<div class="card"><h3>Logwache &amp; Ordner-Scan</h3><p>Folgt im Hintergrund den Logs offener Tabs und meldet nur neue oder kritische Muster; empfängt Syslog von Switches und Firewalls. Der Ordner-Scan prüft alle Hosts eines Ordners auf einmal (auch nachts als Zeitplan) und zeigt, was mehrere gemeinsam haben. <kbd>s</kbd> im Log-Blick eines Switches richtet Syslog an sshTermy ein. Syslog von Absendern ohne gespeicherte Verbindung wird verworfen.</p></div>
<div class="card"><h3>Sicherheitscheck (OSV)</h3><p><kbd>F6</kbd> → <kbd>s</kbd> gleicht die installierten Pakete eines Linux-Servers (und seiner laufenden Container) mit der öffentlichen OSV-Datenbank ab. Zeigt nur, was zählt: Bewertung, Reparatur vorhanden, aktiv ausgenutzt (CISA KEV), von einem Dienst mit offenem Port genutzt. <kbd>u</kbd> fügt den Update-Befehl ein, <kbd>k</kbd> lässt die KI erklären. Online oder ganz offline, für einen ganzen Ordner oder wöchentlich als Zeitplan. Den Rechner verlassen nur Paketnamen und Versionen.</p></div>
<div class="card"><h3>Firmware-Hinweise &amp; Patch-Runde</h3><p><kbd>F6</kbd> → <kbd>s</kbd> am Switch oder an der Firewall prüft die Firmware gegen die NVD (FortiOS, Cisco, Junos, RouterOS, Aruba, PAN-OS …): aktiv ausgenutzt, behoben ab welcher Version. Die Patch-Runde spielt Updates gestaffelt über einen Ordner ein: erst ein Host, nach <kbd>w</kbd> der Rest, mit Vergleich von Diensten, Ports und Logs vorher/nachher und Neustarts einzeln.</p></div>
<div class="card"><h3>Härtungs-Check &amp; Schlüssel-Inventar</h3><p><kbd>F6</kbd> → <kbd>h</kbd> prüft einen Server nur lesend: root- und Passwort-Login, Firewall, Ports offen für alle (Redis, Docker-API …), automatische Updates, ablaufende TLS-Zertifikate, mit Vorschlag je Punkt. <kbd>F6</kbd> → <kbd>a</kbd> oder die Palette zeigt, welche SSH-Schlüssel in welchen <code>authorized_keys</code> eines Ordners stehen, und entfernt den Schlüssel eines ausgeschiedenen Kollegen Host für Host, mit Sicherungskopie.</p></div>
<div class="card"><h3>Sync</h3><p>Ende-zu-Ende-verschlüsselt über OneDrive, Dropbox, iCloud, Syncthing oder WebDAV (Synology, Nextcloud). Tasten, Shell und Schnittstelle gehen auch pro Rechner, Zeitpläne laufen nur auf ihrem Rechner, Favoriten zählen über alle.</p></div>
<div class="card"><h3>Systemprofil</h3><p>Kennt Linux-Distributionen, macOS, Windows und Netzwerk-Dialekte (Aruba, Cisco, Juniper, MikroTik, FortiGate, UniFi …), damit die KI passende Befehle vorschlägt.</p></div>
<div class="card"><h3>Befehlssätze</h3><p>48 Befehlssätze eingebaut (Cisco, Arista, Aruba, Comware, Huawei, Dell, Extreme, Ruckus, Palo Alto, Sophos, FortiGate, pfSense, Proxmox …). Eigene als YAML ergänzen, am Gerät testen oder von der KI entwerfen lassen, per Sync auf allen Rechnern; eigene und Team-Sätze können die eingebauten Sicherheitsregeln nie abschwächen.</p></div>
@@ -236,6 +237,7 @@ sudo apt update && sudo apt install sshtermy</pre></div>
<tr><td><kbd>Alt</kbd>+<kbd>E</kbd> oder <kbd>F6</kbd> → <kbd>l</kbd></td><td>Log-Blick: <kbd>n</kbd> Was ist neu?, <kbd>t</kbd> Zeitleiste, <kbd>x</kbd>/<kbd>X</kbd> Rauschen ausblenden, <kbd>k</kbd> KI erklärt, <kbd>b</kbd> KI-Lagebericht, <kbd>1</kbd>…<kbd>4</kbd> Prüfbefehl, <kbd>w</kbd> Meldungen der Logwache, <kbd>s</kbd> Syslog einrichten (Switch)</td></tr>
<tr><td><kbd>F6</kbd> → <kbd>s</kbd></td><td>Sicherheitscheck (OSV): <kbd>⏎</kbd> Details, <kbd>u</kbd> Update-Befehl einfügen, <kbd>k</kbd> KI erklärt, <kbd>f</kbd> nur reparierbare, <kbd>x</kbd>/<kbd>X</kbd> für Host/Ordner hinnehmen, <kbd>o</kbd> ganzer Ordner, <kbd>c</kbd> kopieren</td></tr>
<tr><td>Palette: <em>Patch-Runde</em></td><td>Updates gestaffelt: <kbd>j</kbd> <kbd>j</kbd> starten, <kbd>w</kbd> nach dem ersten Host weiter, <kbd>x</kbd> nach dem laufenden Host beenden, <kbd>c</kbd> Bericht kopieren. Am Switch zeigt <kbd>F6</kbd> → <kbd>s</kbd> Firmware-Hinweise.</td></tr>
<tr><td><kbd>F6</kbd> → <kbd>h</kbd> / <kbd>a</kbd></td><td>Härtungs-Check (nur lesend) / Schlüssel-Inventar: <kbd>⏎</kbd> wo steht der Schlüssel, <kbd>d</kbd> entfernen (fragt je Host), <kbd>←</kbd> zurück zur Liste, <kbd>c</kbd> kopieren</td></tr>
<tr><td><kbd>F6</kbd> → <kbd>t</kbd> / <kbd>z</kbd></td><td>Live-Graphen: Zeitraum 5 min / 1 h, groß</td></tr>
<tr><td><kbd>F5</kbd> → <kbd>e</kbd></td><td>Server-Datei im eigenen Editor (Speichern lädt hoch)</td></tr>
<tr><td><kbd>F5</kbd> → <kbd>⏎</kbd> / Doppelklick</td><td>Datei ansehen (<kbd>/</kbd> suchen, <kbd>f</kbd> mitlesen, <kbd>w</kbd> umbrechen), <kbd>o</kbd> Standardprogramm</td></tr>
Binary file not shown.
Binary file not shown.
+2
View File
@@ -154,6 +154,7 @@ sudo apt update && sudo apt install sshtermy</pre></div>
<div class="card"><h3>Log watch &amp; folder scan</h3><p>Follows the logs of open tabs in the background and reports only new or critical patterns; receives syslog from switches and firewalls. The folder scan checks every host of a folder at once (also nightly as a schedule) and shows what several hosts share. <kbd>s</kbd> in a switch's log view sets up syslog to sshTermy. Syslog from senders without a saved connection is dropped.</p></div>
<div class="card"><h3>Security check (OSV)</h3><p><kbd>F6</kbd> → <kbd>s</kbd> compares the installed packages of a Linux server (and its running containers) with the public OSV database. Shows only what matters: score, fix available, actively exploited (CISA KEV), used by a service with an open port. <kbd>u</kbd> inserts the update command, <kbd>k</kbd> lets the AI explain. Online or fully offline, for a whole folder or weekly as a schedule. Only package names and versions leave your computer.</p></div>
<div class="card"><h3>Firmware advisories &amp; patch round</h3><p><kbd>F6</kbd> → <kbd>s</kbd> on a switch or firewall checks the firmware against the NVD (FortiOS, Cisco, Junos, RouterOS, Aruba, PAN-OS …): actively exploited, fixed in which version. The patch round installs updates across a folder in stages: first one host, then after <kbd>w</kbd> the rest, comparing services, ports and logs before and after, rebooting one at a time.</p></div>
<div class="card"><h3>Hardening check &amp; key inventory</h3><p><kbd>F6</kbd> → <kbd>h</kbd> checks a server read-only: root and password login, firewall, ports open to everyone (Redis, Docker API …), automatic updates, expiring TLS certificates, with a suggestion for each point. <kbd>F6</kbd> → <kbd>a</kbd> or the palette lists which SSH keys are in which <code>authorized_keys</code> across a folder and removes a former colleague's key host by host, with a backup copy.</p></div>
<div class="card"><h3>Sync</h3><p>End-to-end encrypted via OneDrive, Dropbox, iCloud, Syncthing or WebDAV (Synology, Nextcloud). Keys, shell and serial port can be set per computer, schedules run only on their computer, favorites count across all.</p></div>
<div class="card"><h3>System profile</h3><p>Knows Linux distributions, macOS, Windows and network OS dialects (Aruba, Cisco, Juniper, MikroTik, FortiGate, UniFi …), so the AI suggests matching commands.</p></div>
<div class="card"><h3>Command sets</h3><p>48 command sets built in (Cisco, Arista, Aruba, Comware, Huawei, Dell, Extreme, Ruckus, Palo Alto, Sophos, FortiGate, pfSense, Proxmox …). Add your own as YAML, test it on the device or let the AI draft it, synced to your other computers; own and team sets can never weaken the built-in safety rules.</p></div>
@@ -235,6 +236,7 @@ sudo apt update && sudo apt install sshtermy</pre></div>
<tr><td><kbd>Alt</kbd>+<kbd>E</kbd> or <kbd>F6</kbd> → <kbd>l</kbd></td><td>Log view: <kbd>n</kbd> what's new, <kbd>t</kbd> timeline, <kbd>x</kbd>/<kbd>X</kbd> hide noise, <kbd>k</kbd> AI explains, <kbd>b</kbd> AI status report, <kbd>1</kbd>…<kbd>4</kbd> check command, <kbd>w</kbd> log watch alerts, <kbd>s</kbd> syslog setup (switch)</td></tr>
<tr><td><kbd>F6</kbd> → <kbd>s</kbd></td><td>Security check (OSV): <kbd>⏎</kbd> details, <kbd>u</kbd> insert update command, <kbd>k</kbd> AI explains, <kbd>f</kbd> only fixable, <kbd>x</kbd>/<kbd>X</kbd> accept for host/folder, <kbd>o</kbd> whole folder, <kbd>c</kbd> copy</td></tr>
<tr><td>Palette: <em>Patch round</em></td><td>Staged updates: <kbd>j</kbd> <kbd>j</kbd> start, <kbd>w</kbd> continue after the first host, <kbd>x</kbd> stop after the current host, <kbd>c</kbd> copy report. On a switch <kbd>F6</kbd> → <kbd>s</kbd> shows firmware advisories.</td></tr>
<tr><td><kbd>F6</kbd> → <kbd>h</kbd> / <kbd>a</kbd></td><td>Hardening check (read-only) / key inventory: <kbd>⏎</kbd> where is the key, <kbd>d</kbd> remove (asks per host), <kbd>←</kbd> back to list, <kbd>c</kbd> copy</td></tr>
<tr><td><kbd>F6</kbd> → <kbd>t</kbd> / <kbd>z</kbd></td><td>Live graphs: range 5 min / 1 h, large view</td></tr>
<tr><td><kbd>F5</kbd> → <kbd>e</kbd></td><td>Server file in your own editor (saving uploads it)</td></tr>
<tr><td><kbd>F5</kbd> → <kbd>⏎</kbd> / double-click</td><td>View file (<kbd>/</kbd> search, <kbd>f</kbd> follow, <kbd>w</kbd> wrap), <kbd>o</kbd> default app</td></tr>
+1 -1
View File
@@ -85,7 +85,7 @@
<li><kbd>⇧F10</kbd> moves a tab into its own terminal window.</li>
<li><kbd>Ctrl</kbd>+<kbd>F</kbd> searches the scrollback, <kbd>Ctrl</kbd>+<kbd>E</kbd> jumps to error lines. <kbd>Alt</kbd>+<kbd>S</kbd> searches all open tabs.</li>
<li><kbd>F9</kbd> and <kbd>⇧F1</kbd>…<kbd>⇧F8</kbd>: quick commands, preset for the device (Linux, Windows, Aruba, Cisco, Juniper, MikroTik, FortiGate …).</li>
<li><kbd>F6</kbd> host overview: CPU, RAM, disk, updates on servers, live graphs on Linux (<kbd>t</kbd> 5 min / 1 h, <kbd>z</kbd> large); firmware, ports and VLANs on network devices; <kbd>c</kbd> containers; <kbd>s</kbd> security check: installed packages against the OSV database (score, fix available, actively exploited, used by a running service); on switches and firewalls firmware advisories from the NVD. Palette <em>Patch round</em>: staged updates across a folder, first host, then <kbd>w</kbd> for the rest.</li>
<li><kbd>F6</kbd> host overview: CPU, RAM, disk, updates on servers, live graphs on Linux (<kbd>t</kbd> 5 min / 1 h, <kbd>z</kbd> large); firmware, ports and VLANs on network devices; <kbd>c</kbd> containers; <kbd>s</kbd> security check: installed packages against the OSV database (score, fix available, actively exploited, used by a running service); on switches and firewalls firmware advisories from the NVD. Palette <em>Patch round</em>: staged updates across a folder, first host, then <kbd>w</kbd> for the rest. <kbd>h</kbd> hardening check (read-only), <kbd>a</kbd> key inventory of the <code>authorized_keys</code>.</li>
<li>If the line drops (Wi-Fi, VPN, standby), sshTermy reconnects by itself, restarts tunnels and re-attaches tmux/screen. After waking up or a network change all connections are checked right away.</li>
</ul>
</section>
+2
View File
@@ -166,6 +166,7 @@ export const de = {
['b', 'Config sichern + prüfen'],
['↑ / ↓ · d · v', 'Stand wählen · Diff · ansehen'],
['c · g · t · z', 'Container · Grenzen · Zeitraum · groß'],
['h · a', 'Härtungs-Check · Schlüssel-Inventar'],
['Alt+E / l', 'Log-Blick: n neu · t Zeit · b KI · w Wache · s Syslog'],
['s', 'Sicherheit: u Update · k KI · Switch: Firmware'],
]},
@@ -355,6 +356,7 @@ export const en = {
['b', 'back up switch config + check rules'],
['↑ / ↓ · d · v', 'pick state · diff · view'],
['c · g · t · z', 'containers · limits · range · large'],
['h · a', 'hardening check · key inventory'],
['Alt+E / l', "log view: n new · t time · b AI · w watch · s syslog"],
['s', 'security: u update · k AI · switch: firmware'],
]},
+1 -1
View File
@@ -1 +1 @@
25d1de21630be943f2798a733e6df3adc49264efae83ab2d7205bb9d80bb2d03
6a8b335e4eee56ab1789a98420af8929c836ac6438051c7e3bb9b767322b641b