K-114: SSH root login prompt with sshd drop-in in the install path

prompt_lxc_config asks 'SSH-Root-Login erlauben? [Y/n]' (env-presettable
via SSH_ROOT_LOGIN, validated, normalized to yes|no). The bootstrap passes
the value into the container; configure_ssh_root_login writes
/etc/ssh/sshd_config.d/zz-root-login.conf (yes -> PermitRootLogin yes,
no -> prohibit-password) and reloads sshd.
This commit is contained in:
2026-06-12 14:41:31 +02:00
parent 5f532fe10a
commit aa3ad2f716
8 changed files with 95 additions and 5 deletions
+24 -1
View File
@@ -147,6 +147,16 @@ is_cidr() {
is_ipcfg() { [[ "$1" == "dhcp" ]] || is_cidr "$1"; }
# Ja/Nein-Antworten (Prompts wie "… erlauben? [Y/n]"). Akzeptiert
# deutsch/englisch, normalize_yesno macht daraus kanonisch yes|no.
is_yesno() { is_clean_ascii "$1" && [[ "${1,,}" =~ ^(y|yes|j|ja|n|no|nein)$ ]]; }
normalize_yesno() {
case "${1,,}" in
y|yes|j|ja) printf 'yes' ;;
*) printf 'no' ;;
esac
}
# Space/comma-separated list of IPv4s (DNS prompt). Gesamtstring zuerst
# prüfen — die Wort-Splittung würde eingebettete Newlines sonst verstecken.
is_ipv4_list() {
@@ -311,6 +321,17 @@ prompt_lxc_config() {
else
msg_warn "No network profile for VLAN ${VLAN_TAG:-none}; DHCP DNS will be inherited."
fi
# SSH-Root-Login (Default: ja, Homelab-Komfort). Umgesetzt wird das im
# Install-Pfad per sshd-Drop-in (configure_ssh_root_login, lib/install.func);
# bootstrap_install_script reicht den normalisierten Wert in den Container.
if [[ -z "${SSH_ROOT_LOGIN:-}" ]]; then
prompt_validated SSH_ROOT_LOGIN "SSH-Root-Login erlauben? [Y/n]: " is_yesno "y"
else
require_valid SSH_ROOT_LOGIN is_yesno "SSH root login (y/n)"
fi
SSH_ROOT_LOGIN="$(normalize_yesno "$SSH_ROOT_LOGIN")"
echo " → SSH root login: $SSH_ROOT_LOGIN"
}
# ── template ─────────────────────────────────────────────────────────────────
@@ -408,7 +429,9 @@ bootstrap_install_script() {
pct exec "$CTID" -- bash -c "apt-get update -qq && apt-get install -y -qq curl ca-certificates >/dev/null"
msg_info "Running installer ($url)..."
pct exec "$CTID" -- bash -c "curl -fsSL '$url' -o /root/${APP}-install.sh && bash /root/${APP}-install.sh"
# SSH_ROOT_LOGIN ist durch normalize_yesno kanonisch yes|no — als Env in
# den Container durchreichen (configure_ssh_root_login wertet es aus).
pct exec "$CTID" -- bash -c "curl -fsSL '$url' -o /root/${APP}-install.sh && SSH_ROOT_LOGIN='${SSH_ROOT_LOGIN:-yes}' bash /root/${APP}-install.sh"
}
# ── summary ──────────────────────────────────────────────────────────────────