Fast, agentless-feel security audit for Ubuntu servers. Each server runs a Python 3 script from cron; if any CRITICAL or HIGH finding appears, a Telegram alert is sent. Quiet otherwise.
Designed for personal/small fleets on Hetzner (or any Ubuntu host).
Each run, under a minute on a small server:
- Patching — pending security updates, kernel/openssl/openssh/libc/sudo prioritised as CRITICAL; reboot-required flag; Ubuntu release EOL; unattended-upgrades installed and enabled; stale apt cache.
- SSH —
PermitRootLogin,PasswordAuthentication,PermitEmptyPasswords, protocol version, sshd actually running. Usessshd -Tso includes drop-in configs. - Firewall — ufw / nftables / iptables presence; flags a host with no active firewall as CRITICAL.
- Listening services — anything bound to
0.0.0.0. Sensitive ports (Postgres, MySQL, Redis, Mongo, Elasticsearch, Docker API, Kibana, etc.) on the public interface are CRITICAL; other unexpected public listeners are HIGH (allowlist viaSEC_CHECK_ALLOWED_PORTS). - Users & sudo — extra UID 0 accounts, empty password fields, NOPASSWD entries in sudoers.d.
- File permissions —
/etc/shadow,/etc/gshadow,/etc/ssh/sshd_config,/etc/passwd. - Brute force signals — failed SSH logins in last 24h grouped by IP; fail2ban active when password auth is enabled.
- Kernel hardening —
randomize_va_space,tcp_syncookies,rp_filter, redirects, source routing. - Disk — root and
/var/lognear-full conditions. - Recent admin changes — cron entries and systemd units modified in the last 7 days (worth a manual eyeball).
Severities MEDIUM and LOW are recorded but never alert. See them with
--full.
On each Ubuntu server, as root:
curl -sSL https://raw.githubusercontent.com/sdkfuyr/sec-check/main/install.sh | sudo bashThe installer will:
- Install missing dependencies (
python3,iproute2,procps,ufw). - Drop
check.pyinto/opt/sec-check/. - Prompt for your Telegram bot token and chat ID, send a test message.
- Prompt for cron frequency (hourly / 6h / 12h / daily).
- Write
/etc/cron.d/sec-checkand run one dry-run pass.
Re-running the installer is safe — it detects an existing install and lets you update the config, refresh the script only, or do a full reinstall.
Any prompt can be pre-answered via environment variables. Useful when provisioning many servers with Ansible/SaltStack/cloud-init:
| Variable | Purpose |
|---|---|
SEC_CHECK_TG_TOKEN |
Telegram bot token |
SEC_CHECK_TG_CHAT |
Telegram chat ID |
SEC_CHECK_CRON_CHOICE |
1=hourly, 2=6h, 3=12h, 4=daily |
SEC_CHECK_SKIP_TELEGRAM_TEST |
1 to skip the post-config test send |
SEC_CHECK_MODE |
Reinstall choice (1-4) when an existing install is detected |
SEC_CHECK_TG_TOKEN="..." \
SEC_CHECK_TG_CHAT="..." \
SEC_CHECK_CRON_CHOICE=2 \
curl -sSL https://raw.githubusercontent.com/sdkfuyr/sec-check/main/install.sh \
| sudo -E bash- In Telegram, open a chat with @BotFather →
/newbot→ choose a name and username → copy the API token. - Send any message to your new bot.
- Open
https://api.telegram.org/bot<TOKEN>/getUpdatesin a browser and copy the numeric"chat":{"id":...}value.
The installer prompts for both values.
| Path | Purpose | Mode |
|---|---|---|
/opt/sec-check/check.py |
Audit script | 0750 |
/etc/sec-check.env |
Telegram credentials + allowlist | 0600 |
/var/lib/sec-check/state.json |
Last-alert dedupe state | 0600 |
/etc/cron.d/sec-check |
Cron entry | 0644 |
sudo /opt/sec-check/check.py --dry-run # print findings, do not send
sudo /opt/sec-check/check.py --full # include MEDIUM/LOW
sudo /opt/sec-check/check.py --test-telegram # send a test message
sudo /opt/sec-check/check.py --force-alert # send even if nothing changed
sudo /opt/sec-check/check.py # normal cron-mode runIn cron-mode the script alerts only when at least one CRITICAL or HIGH finding exists, and only re-alerts if the finding set changed or 24h have passed since the last alert.
Edit /etc/sec-check.env:
SEC_CHECK_ALLOWED_PORTS=22,80,443,8080
Public listeners on listed ports stop generating HIGH findings. Sensitive services (databases, message queues, etc.) are still CRITICAL regardless of the allowlist — there's no legitimate reason to expose those.
sudo bash /opt/sec-check/uninstall.sh # remove everything
sudo bash /opt/sec-check/uninstall.sh --keep-config # keep /etc/sec-check.env(Or fetch uninstall.sh from the repo if you no longer have a local copy.)
- No remote scanning, no SSH from your laptop — each server checks itself.
- No web/TLS/database deep checks.
- No Docker container scanning.
- No Hetzner Cloud API calls (so no API token needed).
- No remediation. Findings only.
These were all explicitly out of scope for the first version. Adding any of
them is a check_* function in check.py.
A Docker harness lives in test/. See test/README.md.
cd test
./run.sh # smoke test on clean Ubuntu 22.04
./run.sh --vulnerable # second pass on an intentionally misconfigured image
./run.sh --systemd # systemd-enabled mode for service-state checksIf you've cloned this repo to the target server:
sudo ./install.shThe installer detects a local check.py next to itself and copies it directly,
skipping the curl download.