A Claude Code / agent skill that audits and hardens basic security on a Debian/Ubuntu server over SSH. Always produces a read-only report first, only applies changes after explicit confirmation, and guards SSH changes with a 5-minute automatic rollback so a misconfigured sshd_config cannot lock you out.
Based on the checklist in Server Security for AI Agents — Part 1.
npx skills@latest add zerostaff/server-security-skillWhen the picker shows up, select server-security and whichever agent (Claude Code, Codex, etc.) you want it installed into.
Eight checks, in two batches:
Batch A — safe fixes (no lockout risk):
- System packages up to date;
sudo,curl,ufw,fail2ban,unattended-upgradesinstalled. - A non-root user in the
sudogroup with a populated~/.ssh/authorized_keys. - Keys in
authorized_keysare ed25519 or RSA ≥ 3072 bits. - UFW is active with default-deny incoming, default-allow outgoing, and SSH allowed.
- Unattended-upgrades configured with automatic reboot at 04:00 and unused-kernel cleanup.
- Fail2ban active with the
sshdjail enabled (bantime 1h, findtime 10m, maxretry 5, aggressive mode). visudo -cclean; each sudo user's home directory is mode700.
Batch B — SSH hardening (lockout risk, runs with fail-safe rollback):
/etc/ssh/sshd_config.d/01-hardening.confenforcesPermitRootLogin no,PasswordAuthentication no,PubkeyAuthentication yes,MaxAuthTries 3,LoginGraceTime 30,ClientAliveInterval 300,AllowUsers <deploy>, and disables X11/agent/TCP forwarding. The skill checks alphabetically-earlier drop-in files for conflicting directives (cloud-init images often setPasswordAuthentication yesin00-cloud-init.conf, which would otherwise win).
The skill never reboots, never generates SSH keys on the server, never wipes user-added firewall rules, and never edits sshd_config without scheduling an automatic rollback first.
Before touching /etc/ssh/sshd_config.d/01-hardening.conf the skill:
- Validates the new file with
sshd -t. - Backs up the existing file (if any) to
/tmp. - Schedules a transient
systemd-rununit to fire in 5 minutes that restores the backup and reloads ssh. - Moves the new file into place and reloads ssh.
- Asks you to open a second terminal and confirm
ssh <user>@<host>still works. - Cancels the rollback only after you confirm. Silence rolls it back automatically.
Walk away from the keyboard mid-change and the worst that happens is ssh ends up exactly how it was 5 minutes ago.
Full protocol: skills/server-security/references/ssh-safety.md.
- Target server: Debian 11+ / Ubuntu 20.04+ (or a derivative). Other distros are explicitly out of scope for now.
- Init system: systemd (the rollback uses
systemd-run). - Connection: SSH access to the server with either root or a user with
sudo. Connecting as root is fine on a fresh VPS — the skill will create the non-root user as part of the fixes. - Local agent: any coding agent that supports skills (Claude Code, Codex, etc.) installed via
skills.sh.
This is the universal first-pass for any new server, not a full hardening guide. The skill explicitly does not touch:
- Application-layer config (nginx, postgres, docker daemon, app secrets)
- AppArmor / SELinux profiles
- Network segmentation, VPN-only SSH, port knocking
- 2FA on SSH (TOTP via PAM)
- Centralised logging or SIEM
- CIS / STIG benchmark compliance
See skills/server-security/references/checks.md for the precise scope of each check and the commands used.
.
├── .claude-plugin/
│ └── plugin.json # skills.sh marketplace metadata
├── skills/
│ └── server-security/
│ ├── SKILL.md # main skill instructions
│ └── references/
│ ├── checks.md # per-check detection + remediation commands
│ └── ssh-safety.md # SSH rollback protocol
├── LICENSE
└── README.md
MIT — see LICENSE.