debian13-server

Bootstrap · Hardening · Multi-domaines

Debian 13 (Trixie) — OVH

● Pure Bash ● Debian 13 ● OVH API ● 465 tests
sudo ./debian13-server.sh

Un script. Un serveur. De zero a production.

Decouvrir ↓
17
Bibliotheques
465
Tests
47
Fonctions dm_*
19
Verifications
0
Dependances

Stack complete

Tout ce qu'il faut pour un serveur de production securise, en une seule commande.

🔒

Securite reseau

  • SSH Cle uniquement, port custom, sntrup761 post-quantique
  • UFW Deny-all in/out, whitelist stricte
  • Fail2ban 3 niveaux : standard, custom, recidive
  • GeoIP ipset kernel — 103 pays bloques
🌐

Stack web

  • Apache PHP-FPM, mod_security OWASP CRS, headers defensifs
  • MariaDB Hardening auto, phpMyAdmin URL aleatoire
  • SSL Certbot wildcard DNS-01 (OVH) ou HTTP-01
  • DNS SPF, DKIM, DMARC, CAA, TLSA — auto via HMAC
🛡️

Defense systeme

  • ModSecurity WAF OWASP CRS (SQLi, XSS, LFI, RCE)
  • AppArmor Confinement MAC (Apache, MariaDB, Postfix)
  • auditd Journalisation syscalls sensibles
  • sysctl ASLR, syncookies, kptr_restrict, /tmp noexec

Sous le capot

36 etapes d'installation orchestrees avec checkpoint/resume. Chaque composant est configure, durci et verifie.

🔒

Reseau & acces

SSH · UFW · GeoIP · Fail2ban
  • SSH Port custom (def 65222), cle uniquement, PermitRootLogin=no, 3 essais max
  • Post-quantique KEX sntrup761x25519-sha512, chiffrement ChaCha20-Poly1305 + AES-256-GCM
  • UFW Deny-all ingress + whitelist SSH/80/443 — filtrage egress optionnel (DNS, SMTP, NTP)
  • GeoIP 103 pays bloques via ipset kernel, MAJ hebdo atomique (zero downtime)
  • Fail2ban 9 jails : SSH, Apache-auth, badbots, vulnscan, badagent, post-flood, auth-flood, recidive 7j
  • Login alerts Email a chaque connexion SSH avec geolocalisation IP (ipinfo.io)
🌐

Stack web

Apache · PHP · MariaDB · phpMyAdmin
  • Apache MPM event, mod_headers, mod_rewrite, mod_ssl, mod_deflate, mod_proxy + WebSocket
  • Headers HSTS 2 ans, CSP, X-Frame-Options, X-Content-Type-Options, Permissions-Policy, Referrer-Policy
  • PHP 8.x FPM opcache, expose_php=Off, 10 fonctions dangereuses desactivees (exec, shell_exec, system…)
  • MariaDB Hardening auto : anonymous users supprimes, test DB dropped, privileges flush
  • phpMyAdmin URL aleatoire /dbadmin_<hex>, cookie 30 min, AllowArbitraryServer=false, syslog
  • Erreurs Pages WebGL Three.js 3D, debug IP de confiance, alerte email 5xx (throttle 5 min)
🖧

Certificats & DNS

Let's Encrypt · OVH API · HMAC-SHA1
  • Let's Encrypt HTTP-01 standard ou DNS-01 wildcard *.domain via OVH API
  • OVH API Requetes signees HMAC-SHA1, CRUD records, refresh zone automatique
  • Records auto A, AAAA, www, SPF, DKIM, DMARC, CAA — crees/MAJ en une commande
  • Verification --check-dns resout chaque record, --check-dns --fix auto-corrige via API
  • Renouvellement Timer systemd automatique, relance Apache post-renewal
  • PTR / reverse Configuration automatique du reverse DNS IPv4/IPv6
📧

Email sortant

Postfix · OpenDKIM · SPF · DMARC
  • Postfix Send-only, inet_interfaces=loopback-only, TLS opportuniste, pas de relay
  • OpenDKIM Multi-domaines : cle RSA 2048 bits par domaine, selecteur configurable
  • SPF v=spf1 a mx ip4:{IP} include:mx.ovh.com ~all
  • DMARC p=quarantine, rapports a l'admin, alignement SPF+DKIM
  • Rotation --dkim-rotate cree un selecteur horodate mail{YYYYMMDD}, conserve l'ancien
  • DANE/TLSA Hash du certificat TLS publie dans le DNS pour validation
🛡️

Securite systeme

WAF · AppArmor · auditd · sysctl
  • ModSecurity WAF OWASP CRS : SQLi, XSS, LFI, RCE, scanners — mode DetectionOnly ou blocage
  • AppArmor Profils MAC pour Apache, MariaDB, Postfix (confinement fichiers/reseau)
  • auditd Syscalls sensibles : identite, privileges, cron, reseau, systemd — filtre auid>=1000
  • sysctl ASLR, SYN cookies, kptr_restrict, IP forwarding off, Magic SysRq off
  • /tmp Monte noexec,nosuid,nodev (tmpfs 1 Go) — bloque payload staging
  • sudo Timeout 5 min, log complet /var/log/sudo.log
🔍

Detection & antivirus

ClamAV · rkhunter · AIDE · Logwatch
  • ClamAV Scan quotidien 2h, MAJ signatures freshclam temps reel, alertes email
  • rkhunter Scan hebdo dimanche 3h, whitelist faux positifs Debian, MAJ post-apt
  • AIDE Baseline integrite fichiers, check quotidien 4h, exclusions intelligentes (/var/cache, /tmp…)
  • Logwatch Digest HTML quotidien par email (auth, apache, postfix, syslog)
  • block_hack.sh Analyse ModSec horaire : IP recurrentes → ban permanent UFW
  • WAF par domaine Rate-limiting et regles personnalisees dans /etc/modsecurity/rules.d/
📊

Monitoring & observabilite

Dashboard · Alertes · Healthz · NDJSON
  • Dashboard Temps reel HTML/JS pur, URL secrete + restriction IP, auto-refresh 10s
  • /healthz Endpoint JSON : uptime, load, CPU, disk, memoire, timestamp — LB-compatible
  • Alertes Multi-canal : Slack, Telegram, Discord via webhooks (disk >85%, SSL <14j, queue >50)
  • Logs structures NDJSON dans /var/log/bootstrap_structured.jsonl — pret pour Loki/ELK
  • Rapport audit HTML auto-contenu (--audit-html) : OK/WARN/FAIL par section
  • 19 verifications Services, SSH, web, DNS, DKIM, TLS, ports, fichiers, ressources…
⚙️

DevOps & infrastructure

Backup · Clone · Fleet · Hooks
  • DevTools Git, Node.js (nvm LTS), Rust (rustup), Python 3 (pipx PEP 668), Composer, Symfony CLI
  • Backup 3-2-1 Configs + DKIM + MariaDB + crontab, remote GPG optionnel via rsync SSH
  • Snapshots Crees automatiquement avant chaque operation domaine, --rollback instantane
  • Clonage --clone <ip> : rsync SSH des scripts, DKIM, VHosts, certs, logrotate
  • Fleet Inventaire multi-serveurs (fleet.conf), exec distribue, sync config, status
  • Checkpoint Reprise automatique apres crash — 36 etapes trackees, --fresh pour repartir de zero
  • Hooks Plugins hooks.d/ : pre/post install, domain-add, domain-remove, backup
Idempotent & resilient — Le script peut etre relance a tout moment sans casser ce qui existe. En cas d'interruption, il reprend automatiquement a la derniere etape reussie.

Multi-domaines

Chaque domaine ajoute obtient automatiquement l'integralite de la stack.

📝
Register
🔑
DKIM
⚙️
OpenDKIM
🎨
Parking
🌐
DNS
🔒
SSL
📁
VHosts
📋
Logrotate
#FonctionResultat
1dm_register_domaindomains.conf — domaine:selecteur
2dm_generate_dkim_key/etc/opendkim/keys/{domain}/{sel}.private
3dm_rebuild_opendkimkeytable + signingtable + trustedhosts
4dm_deploy_parkingPage WebGL Three.js 3D + robots.txt
5dm_setup_dnsAPI OVH : A, AAAA, www, SPF, DKIM, DMARC, CAA
6dm_obtain_sslCertbot DNS-01 wildcard ou HTTP-01
7dm_deploy_vhosts000-redirect + 010-https + 020-wildcard
8dm_deploy_logrotate/etc/logrotate.d/apache-vhost-{domain}
Tolerant aux erreurs — Si le DNS echoue (pas de credentials OVH), le VHost est quand meme deploye. Corriger ensuite : --check-dns --fix

Defense en profondeur

9 couches de securite entre Internet et vos donnees.

GeoIP 103 pays bloques — ipset kernel reseau
UFW deny-all + whitelist (SSH, 80, 443) reseau
Fail2ban ban progressif 1h → 24h → 7 jours reseau
ModSecurity WAF OWASP CRS — SQLi, XSS, LFI, RCE app
Apache headers HSTS, CSP, X-Frame, Permissions-Policy app
PHP hardening disable_functions, opcache, expose_php=Off app
AppArmor MAC — Apache, MariaDB, Postfix systeme
auditd journalisation syscalls sensibles systeme
sysctl + /tmp noexec ASLR, syncookies, kptr_restrict systeme
9 couches — du filtrage GeoIP au niveau kernel jusqu'au hardening sysctl.

Operations

Tout se fait via le meme point d'entree.

demarrage-rapide
# Installation complete
$ sudo ./debian13-server.sh

# Mode silencieux
$ sudo ./debian13-server.sh --noninteractive

# Reprendre apres interruption
$ sudo ./debian13-server.sh

# Repartir de zero
$ sudo ./debian13-server.sh --fresh

# Simulation / Audit
$ sudo ./debian13-server.sh --dry-run
$ sudo ./debian13-server.sh --audit
domaines
# Ajouter un domaine
$ sudo ./debian13-server.sh --domain-add example.com

# Lister / verifier
$ sudo ./debian13-server.sh --domain-list
$ sudo ./debian13-server.sh --domain-check

# DNS auto-correction
$ sudo ./debian13-server.sh --check-dns --fix
infra
# Backup
$ sudo ./debian13-server.sh --backup

# Clonage serveur
$ sudo ./debian13-server.sh --clone 10.0.0.2

# Fleet multi-serveurs
$ sudo ./debian13-server.sh --fleet-status
$ sudo ./debian13-server.sh --fleet-exec "apt update"
465
tests unitaires — 43 fichiers — bats-core
make
$ make test           # 465 tests bats-core
$ make lint           # shellcheck
$ make check-syntax   # bash -n
$ make docker-test    # Docker isole