Compare commits

...

2 Commits

Author SHA1 Message Date
root 4f578eea52 Handle LXC limitations for sysctl/auditd and clean UFW SSH rule 2026-05-10 20:30:30 +00:00
root c7bec29f7c Adjust SSH setup defaults and update clone instructions 2026-05-10 20:25:02 +00:00
3 changed files with 40 additions and 10 deletions
+21 -3
View File
@@ -4,9 +4,9 @@ Standardisierter Installationsprozess fuer neue Ubuntu-LXC-Container.
Installiert und **direkt vorkonfiguriert**:
- `fail2ban`: SSH/SSHD-DDoS + Recidive-Jail, UFW-Ban-Action
- `ufw`: default deny incoming, allow outgoing, SSH-Rate-Limit, 80/443 erlaubt
- `ufw`: default deny incoming, allow outgoing, SSH freigegeben, 80/443 erlaubt
- `unattended-upgrades`: taegliche Security-Updates aktiv
- `openssh-server`: Basishardening via `sshd_config.d`
- `openssh-server`: SSH automatisch installiert und konfiguriert
- `auditd`: grundlegende Audit-Regeln fuer sensible Dateien
- `sysctl`: Kernel/Netzwerk-Hardening-Basis
- `nodejs`, `npm`, `@openai/codex`
@@ -14,7 +14,7 @@ Installiert und **direkt vorkonfiguriert**:
## Standardprozess nach Download
```bash
git clone https://gitea.kanu1.duckdns.org/Kanu/Sicherheit.git
git clone http://gitea.kanu1.duckdns.org:3000/Kanu/Sicherheit.git
cd Sicherheit
chmod +x bin/sicherheit-install scripts/bootstrap_ubuntu_lxc_security.sh
./bin/sicherheit-install
@@ -27,6 +27,24 @@ sudo ln -sf "$(pwd)/bin/sicherheit-install" /usr/local/bin/sicherheit-install
sudo sicherheit-install
```
## SSH Linux Einrichten (automatisch im Skript enthalten)
Das Skript fuehrt diese Punkte automatisch aus:
```bash
sudo apt update
sudo apt install -y openssh-server
sudo ufw allow ssh
sudo ufw status
# PermitRootLogin yes wird gesetzt
sudo systemctl restart ssh
```
## Hinweis fuer LXC
In unprivilegierten LXC-Containern koennen `sysctl`-Keys und `auditd` teilweise nicht gesetzt/gestartet werden.
Das Skript erkennt Container und ueberspringt diese Schritte automatisch, statt mit Fehlern abzubrechen.
## Wichtige Konfigurationen
- `config/fail2ban/jail.local`
+2 -2
View File
@@ -1,7 +1,7 @@
# Managed by sicherheit-install
Protocol 2
PermitRootLogin prohibit-password
PasswordAuthentication no
PermitRootLogin yes
PasswordAuthentication yes
PubkeyAuthentication yes
PermitEmptyPasswords no
X11Forwarding no
+17 -5
View File
@@ -42,6 +42,10 @@ log() {
echo "[sicherheit-install] $*"
}
is_container() {
systemd-detect-virt --quiet --container
}
copy_cfg() {
local src="$1"
local dst="$2"
@@ -71,7 +75,7 @@ copy_cfg "${CONFIG_DIR}/ufw/after.rules" "/etc/ufw/after.rules"
ufw default deny incoming || true
ufw default allow outgoing || true
ufw logging medium || true
ufw limit OpenSSH || true
ufw allow ssh || true
ufw allow 80/tcp || true
ufw allow 443/tcp || true
ufw --force enable || true
@@ -82,13 +86,21 @@ sshd -t && systemctl restart ssh || true
log "7/10 sysctl Hardening setzen"
copy_cfg "${CONFIG_DIR}/sysctl/99-sicherheit.conf" "/etc/sysctl.d/99-sicherheit.conf"
sysctl --system || true
if is_container; then
log "Container erkannt: sysctl --system wird uebersprungen (teilweise read-only in LXC)"
else
sysctl --system || true
fi
log "8/10 auditd Regeln setzen"
copy_cfg "${CONFIG_DIR}/auditd/hardening.rules" "/etc/audit/rules.d/hardening.rules"
augenrules --load || true
systemctl enable auditd || true
systemctl restart auditd || true
if is_container; then
log "Container erkannt: auditd service/augenrules wird uebersprungen"
else
augenrules --load || true
systemctl enable auditd || true
systemctl restart auditd || true
fi
log "9/10 Node.js ${NODE_MAJOR} installieren"
if ! command -v node >/dev/null 2>&1; then