vps-security-enhancement-scripts README

The project's README from github.com/0x10debug/vps-security-enhancement-scripts. As one markdown file: README.md.

VPS Security Enhancement Scripts — Harden Your VPS from First Login to Incident Response

Test Report: This release passed a full aviation-grade test (126 tests, Docker Ubuntu 22.04, 100% pass rate after 3 bug fixes). See the Test Report for details.

Changelog (2026-09-02): 3 bugs found and fixed during v4.0.0 full test:

  • bigdata_security_audit.sh: removed unused SECTION_FILTER variable (SC2034)
  • stig_compliance_check.sh: fixed printf %d receiving dual output from grep -c || echo 0 (invalid number error in severity breakdown)
  • cis_benchmark_audit.sh: fixed JSON report invalid due to unescaped control characters (newline/tab/CR) in evidence and desc fields

CI

A security-first interactive bash script for VPS hardening, with a scenario-driven handbook and cheatsheets included. One script, zero dependencies, one command to start — plus a real handbook that tells you why, not just how.

This is a living repo: the script and handbook expand by security direction over time. The current release ships a 3200-line interactive script + 20-chapter handbook + 4 cheatsheets. Future iterations add more depth per layer.

Quick Start

wget -O vps_security_enhance.sh https://raw.githubusercontent.com/0x10debug/vps-security-enhancement-scripts/main/vps_security_enhance.sh && chmod +x vps_security_enhance.sh && ./vps_security_enhance.sh

On a fresh server, select a1 Full Security Init — completes in ~10 minutes: system update → firewall → BBR → swap → Fail2Ban → kernel hardening.

After installing the global command, type secure-vps from anywhere to launch.

What It Does

The script (vps_security_enhance.sh) is organized by security layers, not by ops workflow:

Zone Layer Features
A · Quick — Full security init (update + firewall + BBR + swap + Fail2Ban + kernel)
B · Access Security L4 Network SSH hardening, firewall (UFW/Firewalld), intrusion ban (Fail2Ban + CrowdSec with iptables/nginx/Cloudflare bouncers)
C · Defense in Depth L0-L3 Baseline scan, kernel hardening, audit & integrity (auditd/AIDE/Rkhunter/Lynis), password & access control
D · Secure Ops — Container security (Docker/Portainer/Watchtower/1Panel), security monitoring (Uptime Kuma), network diagnostics, system tools
E · Incident & Recovery L6 Detection Emergency triage (compromise check, login history, suspicious cron), forensic triage collection (read-only, evidence chain), performance & resource (BBR/swap/bench)
Z · Maintenance — Global command, self-update

Security Layer Roadmap

The 7-layer architecture (L0 → L6) guides the iteration plan. Each layer maps to dedicated scripts and handbook chapters added over the 9-day iteration cycle:

Layer Scope Status
L0 Compliance audit (CIS Benchmark, STIG) CIS + STIG audit scripts added
L1 Container & Kubernetes security Docker audit + Dockerfile hardener + K8s audit + runtime security (Falco/Tetragon) added
L2 Cloud platform CIS baselines (AWS/GCP/Azure) AWS + GCP + Azure CIS baseline audit added
L3 Data security (database hardening, big-data SSL/audit) Database hardening + Big data SSL setup + Big data security audit added
L4 Network & perimeter (zero-trust, WAF) Zero trust (WireGuard + Headscale) + WAF (Coraza + CRS v4) added
L5 Key & certificate security (TLS lifecycle, secret scanning) TLS lifecycle (acme.sh, 29 DNS providers, ECC+RSA, auto-renew, deploy hooks, monitoring) + Secret scanning (gitleaks + trufflehog, git history, CI integration) added
L6 Detection & response (CrowdSec, incident triage) CrowdSec deployment (install, scenarios, iptables/nginx/Cloudflare bouncers, email/webhook/Slack/Discord alerts, hub management, 15-check audit) + Incident triage forensic collection (read-only, order-of-volatility, evidence chain, 16-check audit, tar.gz archive + manifest) added

See dev-docs/0015 for the full branch strategy.

Security Design

Three Iron Rules (built into the script)

  1. Snapshot → Validate → Rollback: Before modifying sshd_config / daemon.json / sudoers, a timestamped snapshot is saved. Before restarting services, sshd -t / visudo -cf validation runs. If validation fails, automatic rollback — never locks you out.
  2. Linkage Consistency: When changing SSH port, Fail2Ban ban port is automatically synced. Rollback is also linked.
  3. Read-Only First: Scans and audits never modify the system. All destructive operations require confirmation.

Supply Chain Audit

Risk Area Status Notes
Hardcoded secrets ✅ Clean No passwords, keys, or IPs hardcoded
External script execution ⚠️ Documented Docker install (get.docker.com), CrowdSec install, YABS, bench.sh, NextTrace, IPQuality, Fusion Monster — all from official sources, all require user confirmation
eval usage ✅ Safe Only used for package manager commands (eval "$PKG_INSTALL foo") — no user input reaches eval
rm -rf usage ✅ Guarded Only in Docker uninstall, requires double confirmation
Self-update mechanism ✅ HTTPS Downloads from GitHub raw over HTTPS
Input validation ✅ Present All interactive inputs validated before use
shellcheck ✅ Clean Zero warnings at -S warning level

Handbook (Included)

21 scenario-driven chapters organized by security layer. Each follows "Problem → Investigate → Fix → Verify":

Chapter Topic Security Angle
01 First Login Security First 30 minutes: assessment & hardening
02 Security Baseline SSH, firewall, Fail2Ban/CrowdSec, kernel, Docker UFW bypass, password policy
03 Incident Response "I've been hacked" first 10 minutes, compromise detection, recovery
04 Security Monitoring TLS expiry, SSH unreachable, intrusion detection, log management
05 Backup Security Backup as a safety net: credential protection, recovery drills
06 Container Security Docker UFW bypass, isolation, resource limits
07 Network Security Diagnostics Firewall, TLS, IP quality troubleshooting
08 Resource Security Resource exhaustion defense, crypto performance
09 CIS & STIG Compliance Automated compliance audit against CIS Benchmarks and DISA STIG
10 Container Security Audit CIS Docker Benchmark audit + Dockerfile hardening (18 rules, auto-fix, SARIF)
11 Kubernetes Security Audit CIS Kubernetes Benchmark audit (60+ checks, control plane + worker + policies + workload)
12 Runtime Security Falco + Tetragon eBPF-based runtime detection and enforcement
13 Cloud CIS Baseline AWS + GCP + Azure CIS Foundations Benchmark audit (40+ checks per provider)
14 Database Hardening MySQL + PostgreSQL + Redis + MongoDB CIS benchmark audit + hardened config generation
15 Big Data Security Hadoop/Kafka/HBase/Cassandra SSL/TLS setup + Hadoop/Spark security audit
16 Network Zero Trust WireGuard + Headscale mesh VPN, ACL policy, CrowdSec integration, GeoIP filtering
17 WAF Deployment Coraza + OWASP CRS v4, Caddy/Nginx/HAProxy integration, rule tuning, false positive handling
18 TLS Automation acme.sh lifecycle management, DNS-01 vs HTTP-01, 29 DNS providers, ECC/RSA, auto-renew, deploy hooks, monitoring
19 Secret Management gitleaks + trufflehog scanning, git history audit, CI/pre-commit integration, key leak emergency response
20 CrowdSec Deployment CrowdSec vs fail2ban, engine + bouncer + scenario architecture, iptables/nginx/Cloudflare bouncers, email/webhook/Slack/Discord alerts, centralized console, 15-check audit
21 Incident Response & Forensics NIST incident lifecycle, forensic triage methodology, order of volatility, evidence chain of custody, containment strategies, post-incident analysis

Cheatsheets

5 one-page printable reference cards:

Cheatsheet Content
security-commands.md Security-related command quick reference
container-security-commands.md Container security commands
systemd-commands.md Service management, journalctl, targets, timers
security-troubleshooting-tree.md 7 decision trees: SSH fail, service unreachable, disk full, high CPU, container fail, slow website, suspicious activity
forensics-commands.md Forensic triage: process, network, filesystem, log, memory, persistence, evidence collection

Script vs Modular: Which to Use?

Need Use
Quick start, one command, menu-driven vps_security_enhance.sh (this repo)
Modular, CLI-driven, per-module control vps-bootstrap
CIS benchmark audit, drift detection security-audit

Both vps_security_enhance.sh and vps-bootstrap cover SSH/firewall/Fail2Ban/kernel hardening — they're two entry points to the same capability. The script is for "I just want it done", the modular tools are for "I want to control each step and integrate with other tools".

Full 0x10debug VPS Tool Suite

System Requirements

Credits

Benchmark and detection capabilities use: YABS · bench.sh · NextTrace · Fusion Monster · IPQuality · Lynis · Endlessh. Intrusion detection integrates CrowdSec. App deployment uses Docker and 1Panel official scripts.

Community

License

MIT © 2026 0x10debug

vps-security-enhancement-scripts (0x10debug/vps-security-enhancement-scripts)

Searching Database…

这是什么?它是一个安全优先的交互式 bash 脚本,用于加固全新的 VPS 或云服务器,并附有一本场景驱动手册和可打印的速查表,解释每项修复为什么重要,而不只是怎么运行。
它只是一个脚本,还是包含更多内容?它在同一发布中包含三样东西:一个 3200 行的交互式 bash 脚本、一本按章节组织的手册和一套速查表,而且随着新安全层的加入,这三者都会随时间不断扩充。
我怎么在我的服务器上把它跑起来?在全新服务器上运行脚本并选择菜单选项“a1 Full Security Init”,大约 10 分钟完成,涵盖系统更新、防火墙、BBR、swap、Fail2Ban 和内核加固。安装一次全局命令后,你在任何地方只需输入 secure-vps 即可再次启动。
运行它之前需要安装什么吗?不需要,该脚本设计为零依赖——你只需要在受支持的 Linux 发行版上有 root 权限;脚本所需的组件(Docker、CrowdSec 等)只在你选择这些功能时才按需拉取。
加固 SSH 设置会不会把我自己锁在服务器外面?脚本的设计就是为了避免这种情况:在改动 sshd_config、daemon.json 或 sudoers 等文件之前,它会保存带时间戳的快照,并在重启任何服务之前验证更改(sshd -t、visudo -cf),如果验证失败会自动回滚。
它支持哪些操作系统?Ubuntu 20.04+、Debian 10+、CentOS 7/8、AlmaLinux 和 Rocky Linux,需以 root 权限运行,最好在干净的系统镜像上使用。
它与作者的 vps-bootstrap 工具有什么不同?这个脚本是“菜单驱动、我只想把它搞定”式的入口,一次运行即覆盖 SSH、防火墙、Fail2Ban 和内核加固;而 vps-bootstrap 是一个模块化命令行工具,用于单独控制每个步骤并与其他工具集成。
自带的手册实际涵盖哪些内容?21 个场景驱动章节,遵循“问题 → 排查 → 修复 → 验证”的格式,从首次登录安全和事件响应一直讲到 Kubernetes 审计、云 CIS 基线、TLS 自动化和 CrowdSec 部署。
这个项目的长期路线图是什么?它遵循一个 7 层计划(从 L0 合规审计到 L6 检测与响应),会逐步添加针对容器、云 CIS 基线、数据库、零信任网络、TLS/密钥管理和事件取证的脚本与手册章节。
运行审计或扫描会改动我的系统吗?不会——扫描和审计在设计上严格只读,任何破坏性操作(如 Docker 卸载流程)在执行前都需要明确的双重确认。
Creator
0x10debug
Size
0.7 MB
Stars
239
Updated
CommitSep 06
Age
2mo
Commits · 90 Days