Files
server-reorg-playbook/playbooks/SERVER_PLAYBOOK_v1.1.md
2025-12-04 14:37:28 +01:00

233 lines
4.0 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# SERVER PLAYBOOK v1.1
*Erweiterte Version mit SSH‑Key‑Ökosystem & FileDrop‑Struktur*
Dieses Playbook beschreibt einen vollständigen, iterativen Modernisierungsprozess für einen Linux‑Server.
Version **1.1** ergänzt:
- Passwortlose SSH‑Authentifizierung zwischen allen Geräten des Users *stephan*
- Zentrale FileDrop‑Struktur zur einfachen Dateiübertragung
- Aktualisierte Firewall‑Regeln
---
# 🧭 Gesamtüberblick über die Iterationen
1. **Sicherheit (SSH, Fail2ban, Samba, Firewall)**
2. **Docker-Modernisierung**
3. **Serverordner-Struktur**
4. **Monitoring & Logging**
5. **Backup-Strategie**
6. **Infrastructure-as-Code (optional)**
7. **NEU: SSH-Key-Ökosystem & FileDrop (v1.1)**
---
# Iteration 1 – Sicherheit herstellen
## 1. SSH Hardening
```
PermitRootLogin no
PasswordAuthentication no
PubkeyAuthentication yes
```
Restart:
```
systemctl restart ssh
```
## 2. Fail2ban reparieren
```
mkdir -p /var/log
touch /var/log/auth.log
chown syslog:adm /var/log/auth.log
systemctl restart rsyslog
systemctl restart fail2ban
```
## 3. Samba absichern
```
ufw default deny incoming
ufw default allow outgoing
ufw allow from 192.168.12.0/23 to any port 445
ufw allow from 192.168.12.0/23 to any port 139
ufw deny 445
ufw deny 139
ufw enable
```
## 4. Docker-UI-Ports absichern
```
ufw deny 3000
ufw deny 2222
ufw deny 5000
ufw deny 9000
ufw deny 9443
ufw deny 81
```
## 5. Fehlerhafte fstab-Einträge korrigieren
```
nano /etc/fstab
systemctl daemon-reload
```
---
# Iteration 2 – Docker Modernisierung
## Zentrales Netzwerk anlegen
```
docker network create wlkns-net
```
## compose.yml vereinheitlichen
```
networks:
default:
external: true
name: wlkns-net
```
## Standard-Verzeichnisstruktur
```
/docker/
compose/
env/
volumes/
```
## Alte Netzwerke entfernen
```
docker network rm <netz>
```
---
# Iteration 3 – Serverstruktur standardisieren
## Zielstruktur
```
/srv/
gitea/
oidc/
nginx/
minecraft/
mumble/
/docker/
compose/
volumes/
env/
/data/
db/
media/
backups/
/backup/
```
---
# Iteration 4 – Monitoring & Logging
- journald konfigurieren
- Docker-Logging-Treiber optimieren
- Node Exporter / Grafana Agent installieren
---
# Iteration 5 – Backup-Strategie
- daily / weekly / monthly Backups
- systemd timer
- Restore-Test durchführen
---
# Iteration 6 – Optional: Infrastructure-as-Code
- compose.yml versionieren
- .env trennen
- Rebuild-Dokumentation erstellen
---
# Iteration 7 – SSH-Key-Ökosystem & FileDrop (NEU in v1.1)
Diese Iteration ermöglicht:
- Passwortlose SSH-Logins von allen Geräten (User: **stephan**)
- Dateiübertragung ohne Passworteingabe
- Einheitliche Key-Struktur auf allen Clients
- Zentralen Upload-Ordner auf dem Server
---
## 1. Auf jedem Client einen SSH-Key erzeugen (falls nicht vorhanden)
```
ssh-keygen -t ed25519 -C "stephan@<gerät>"
```
Key liegt danach unter:
```
~/.ssh/id_ed25519
~/.ssh/id_ed25519.pub
```
---
## 2. Public Key auf den Server übertragen
Empfohlener Weg:
```
ssh-copy-id stephan@srv01
```
Alternativ:
```
cat ~/.ssh/id_ed25519.pub | ssh stephan@srv01 'mkdir -p ~/.ssh && cat >> ~/.ssh/authorized_keys'
```
---
## 3. SSH-Konfiguration für komfortablen Zugriff
Client-seitige Datei:
```
~/.ssh/config
```
Beispiel:
```
Host srv01
HostName 192.168.12.1
User stephan
IdentityFile ~/.ssh/id_ed25519
```
Jetzt reicht:
```
ssh srv01
```
---
## 4. SSH nur im LAN erlauben (Firewall)
```
ufw allow from 192.168.12.0/23 to any port 22
ufw deny 22
```
---
## 5. FileDrop-Struktur auf dem Server anlegen
```
sudo mkdir -p /srv/filedrop/stephan
sudo chown stephan:stephan /srv/filedrop/stephan
chmod 700 /srv/filedrop/stephan
```
Upload:
```
scp datei.txt srv01:/srv/filedrop/stephan/
```
---
# Abschluss
Version **1.1** des Playbooks erweitert den gesamten Modernisierungsprozess um ein sicheres und konsistentes SSH-Key-Ökosystem sowie eine zentrale FileDrop-Infrastruktur.
Alle Iterationen bleiben modular, ohne Downtime und jederzeit pausierbar.