vps-audit

nuver-labsMIT活跃维护

一个零依赖的轻量 Bash 脚本,用来给 Linux 服务器做安全与性能审计,并监控基础设施状态,适合在 CI/CD 或运维巡检中快速体检机器。

lightweight, dependency-free bash script for security, performance auditing and infrastructure monitoring of Linux servers.

v0.2.0发布于 2026-08-10 11:13 UTC3,280star +29 / 7 天313fork同步于 2026-11-10 23:42 UTC

怎么上手

由 README 提炼,执行前请确认
wget https://raw.githubusercontent.com/Nuver-Labs/vps-audit/main/vps-audit.sh
chmod +x vps-audit.sh
sudo ./vps-audit.sh
硬件要求按 README 说明

README 未说明硬件要求;仅需 Ubuntu/Debian 系 Linux 系统与 root 或 sudo 权限,无 GPU 或显存需求

下载:源码 zip·GitHub Releases(安装包)本站不镜像安装包

项目说明

由 README 自动翻译提炼

一个无依赖的 Bash 脚本,给 Linux 服务器做安全与性能审计并生成报告

一个零依赖的轻量 Bash 脚本,用来给 Linux 服务器做安全与性能审计,并监控基础设施状态,适合在 CI/CD 或运维巡检中快速体检机器。

核心能力

  • 检查 SSH 配置、防火墙、Fail2ban/CrowdSec 与失败登录
  • 检测开放端口、运行服务、SUID 文件与密码策略
  • 监控磁盘、内存、CPU 使用率与活跃网络连接
  • 按 PASS/WARN/FAIL 三色输出并生成带建议的报告文件
  • 阈值与文件路径由脚本顶部变量集中配置

容易踩的坑

仅支持 Debian/Ubuntu 系系统,其他发行版检查可能失效;需 root 或 sudo 运行,否则部分检查无法执行;报告默认写到当前目录,可用 DEFAULT_REPORT_DIR 修改

内容由模型根据 README 生成,可能不完整或不准确,以官方文档为准。看原文 README

最近发版

2 个版本v0.2.0
  1. v0.2.0最新正式版2026-08-10 · 2026-08-10 11:13 UTC

    Fail2ban SSH jail port alignment check

    New check that catches a failure mode where fail2ban appears to be working but blocks nothing.

    fail2ban's [sshd] jail inherits port = ssh (port 22) from jail.conf. If sshd listens on a non-standard port, the generated firewall rule reads tcp dport 22 ... reject and every ban is a silent no-op. fail2ban-client status still reports the bans as successful, so nothing looks wrong from the outside.

    This was found on a live host running SSH on port 2022: roughly 114,000 brute force attempts over a month, 209 "successful" bans, none of which blocked anything. One source IP sustained the attack for 16 consecutive days without ever being meaningfully blocked.

    What the check does

    • Resolves the effective SSH port from sshd -T, falling back to the existing config grep
    • Compares it against the jail port, honouring fail2ban's file precedence: jail.conf, jail.d/*.conf, jail.local, jail.d/*.local
    • Resolves service names (ssh), comma lists (ssh,2222) and ranges (0:65535)
    • Treats an allports banaction as covering every port
    • Reports WARN when the [sshd] jail is disabled entirely

    Example failing output:

    [FAIL] Fail2ban Port Alignment - The fail2ban [sshd] jail blocks port 'ssh' but SSH
    listens on 2022 - every ban is silently ineffective. Set 'port = 2022' in
    /etc/fail2ban/jail.local, or use banaction = nftables[type=allports]
    

    Other changes

    • New FAIL2BAN_CONFIG_DIR configuration variable (defaults to /etc/fail2ban)
    • Version string bumped to 0.2.0

    Full Changelog: https://github.com/Nuver-Labs/vps-audit/compare/v0.1.0...v0.2.0

  2. v0.1.02026-08-10 · 2026-08-10 06:03 UTC
    查看更新说明

    First tagged release of vps-audit, a single-file bash script that audits the security and performance posture of a Linux server. No dependencies beyond what a stock Debian or Ubuntu install already ships.

    Usage

    curl -O https://raw.githubusercontent.com/Nuver-Labs/vps-audit/main/vps-audit.sh
    chmod +x vps-audit.sh
    sudo ./vps-audit.sh
    

    Every check prints PASS, WARN or FAIL with a short explanation of why, and the whole run is also written to a timestamped report file.

    What it checks

    Security:

    • SSH root login, password authentication, and non-default or unprivileged ports, including Include overrides
    • Firewall status across UFW, firewalld, iptables and nftables
    • Intrusion prevention via Fail2ban or CrowdSec, including containerized installs
    • Failed login attempts, read from auth.log or from journald on Debian 11 and newer
    • Pending system updates
    • Running service count, listening ports, and how many are publicly exposed
    • Sudo logging
    • Password policy via pwquality.conf
    • SUID files outside standard locations

    Performance:

    • Disk, memory and CPU usage, load average, and active connections

    Configuration

    Thresholds and file paths are plain variables at the top of the script, so you can retune the PASS/WARN/FAIL bands or point a check at a non-standard path without touching the logic. The Customization section of the README documents each one.

    Known limitations

    • Targets Debian and Ubuntu. The update check assumes apt, and package detection assumes dpkg.
    • Sudo logging reads /etc/sudoers only, not sudoers.d.
    • Requires root or sudo.

    Thanks

    To everyone who has sent a patch: @latetedemelon, @alvarosaavedrau, @Un1q32, @davefatkin, @jnsvgt, @kyle-mckay, @idosysstuff, @xgboosted, @neod123, @DazEdword and @aafmj.

用户点评

登录用户的真实使用记录,可按版本和硬件筛选
共 0 条

    还没有人点评。第一个说出真实体验的人最有价值。

    README 原文

    未翻译

    VPS Security Audit Script

    A comprehensive Bash script for auditing the security and performance of your VPS (Virtual Private Server). This tool performs various security checks and provides a detailed report with recommendations for improvements.

    nuverlabs.com/vps-audit · a Nuver Labs project

    Sample Output

    Features

    Security Checks

    • SSH Configuration   - Root login status   - Password authentication   - Non-default port usage
    • Firewall Status (UFW/firewalld/iptables/nftables)
    • Intrusion Prevention (Fail2ban/CrowdSec) Configuration
      • Fail2ban SSH jail port alignment (catches bans that silently do nothing)
    • Failed Login Attempts
    • System Updates Status
    • Running Services Analysis
    • Open Ports Detection
    • Sudo Logging Configuration
    • Password Policy Enforcement (via pwquality.conf)
    • SUID Files Detection

    Performance Monitoring

    • Disk Space Usage
    • Memory Usage
    • CPU Usage
    • Active Internet Connections

    Requirements

    • Ubuntu/Debian-based Linux system
    • Root access or sudo privileges
    • Basic packages (most are pre-installed):
      • ufw
      • systemd
      • netstat/ss
      • grep
      • awk

    Installation

    1. Download the script:
    wget https://raw.githubusercontent.com/Nuver-Labs/vps-audit/main/vps-audit.sh
    # or
    curl -O https://raw.githubusercontent.com/Nuver-Labs/vps-audit/main/vps-audit.sh
    
    1. Make the script executable:
    chmod +x vps-audit.sh
    

    Usage

    Run the script with sudo privileges:

    sudo ./vps-audit.sh
    

    The script will:

    1. Perform all security checks
    2. Display results in real-time with color coding:
      • 🟢 [PASS] - Check passed successfully
      • 🟡 [WARN] - Potential issues detected
      • 🔴 [FAIL] - Critical issues found
    3. Generate a detailed report file: vps-audit-report-[TIMESTAMP].txt

    Output Format

    The script provides two types of output:

    1. Real-time console output with color coding:
    [PASS] SSH Root Login - Root login is properly disabled in SSH configuration
    [WARN] SSH Port - Using default port 22 - consider changing to a non-standard port
    [FAIL] Firewall Status - UFW firewall is not active - your system is exposed
    
    1. A detailed report file containing:
      • All check results
      • Specific recommendations for failed checks
      • System resource usage statistics
      • Timestamp of the audit

    Customization

    The script's behavior, file paths, and scoring limits are fully controlled by variables defined in the Configuration section at the top of the script file.

    1. Dynamic Thresholds for PASS/WARN/FAIL Status

    These variables define the numerical limits that trigger a WARN or FAIL status.

    VariableDefault ValueCheckDescription
    RESOURCE_WARN50Resource UsageWARN if Disk/Memory/CPU usage is between 50-80%.
    RESOURCE_FAIL80Resource UsageFAIL if Disk/Memory/CPU usage is more than 80%.
    SERVICES_WARN20Running ServicesWARN if between 20-40 services are running.
    SERVICES_FAIL40Running ServicesFAIL if more than 40 services are running.
    LOGINS_WARN10Failed LoginsWARN if between 10-50 failed login attempts are detected.
    LOGINS_FAIL50Failed LoginsFAIL if more than 50 failed login attempts are detected.
    OPEN_PORTS_WARN10Open PortsWARN if between 10-20 listening ports are found.
    OPEN_PORTS_FAIL20Open PortsFAIL if more than 20 listening ports are found.
    PASSWORD_MINLEN12Password PolicyPASS if minlen in pwquality.conf is at least this value.

    2. Report Output and Ownership

    These variables control where the report is saved and the file permissions.

    VariableDefault ValueDescription
    DEFAULT_REPORT_DIR. (The current directory)The directory where the report file will be saved.
    ENABLE_CHOWNfalseIf true, sets ownership of the report file and (if newly created) the report directory to REPORT_CHOWN_OWNER.
    REPORT_CHOWN_OWNER${SUDO_USER:-$(id -un)}:<their group>The target user:group for chown. Defaults to the user who invoked sudo, so reports are not left owned by root.
    REPORT_FILENAMEvps-audit-report-$(TIMESTAMP).txtThe template name for the generated report file.

    3. Security Check File Paths

    You can adjust the paths the script uses to check critical configuration files:

    VariableDefault ValueDescription
    OS_RELEASE_FILE/etc/os-releasePath to the Operating System release file.
    REBOOT_REQUIRED_FILE/var/run/reboot-requiredFile indicating a system restart is needed.
    SSH_CONFIG_FILE/etc/ssh/sshd_configMain SSH daemon configuration file.
    AUTH_LOG_FILE/var/log/auth.logLog file checked for failed login attempts.
    SUDOERS_FILE/etc/sudoersFile checked for sudo logging configuration.
    PASSWORD_QUALITY_CONF/etc/security/pwquality.confPassword complexity policy configuration file.
    FAIL2BAN_CONFIG_DIR/etc/fail2banFail2ban config directory, read to verify the SSH jail port.

    Best Practices

    1. Run the audit regularly (e.g., weekly) to maintain security
    2. Review the generated report thoroughly
    3. Address any FAIL status immediately
    4. Investigate WARN status during maintenance
    5. Keep the script updated with your security policies

    Limitations

    • Designed for Debian/Ubuntu-based systems
    • Requires root/sudo access
    • Some checks may need customization for specific environments
    • Not a replacement for professional security audit

    Contributing

    Feel free to submit issues and enhancement requests!

    License

    This project is licensed under the MIT License - see the LICENSE file for details.


    About

    vps-audit is built and maintained by Nuver Labs.

    Security Notice

    While this script helps identify common security issues, it should not be your only security measure. Always:

    • Keep your system updated
    • Monitor logs regularly
    • Follow security best practices
    • Consider professional security audits for critical systems

    Support

    For support, please:

    1. Check the existing issues
    2. Create a new issue with detailed information
    3. Provide the output of the script and your system information

    Stay secure! 🔒