Skip to content

server-kit · because AI

Check every server before the bots do.

server-kit is a free, open-source package I wrote for Laravel projects. From inside the project I’m already working on, it does the hard parts of putting it on Ubuntu servers. Then it checks every server, every day, so I catch the mistakes everyone eventually makes before the bots do.

  • ✓Servers set up securely. Key-only SSH with no root login, a firewall that blocks everything not configured, fail2ban, and automatic security updates, on Ubuntu 26.04 or later.
  • ✓Users and permissions done right. An admin user with sudo, an app user without it, and each folder and the .env readable only by what needs it.
  • ✓Laravel deployed properly. The server pulls the pushed commit, then Composer, migrations and caches. The front end is built on my computer and uploaded, so Node never runs on the server.
  • ✓One glance every morning. health --list puts every server on one line with its passed, warned and failed checks. The one that needs attention stands out; the full check says how to fix it.
  • ✓Logins stay on my computer. Server addresses and keys live in my own .env. server-kit is a development package, so it isn’t even installed on the servers.
  • ✓Nothing to pay for. No subscription and no agent on the servers: just SSH, from the project.
server-kit on GitHub ↗ Work in progress: published so the work can be seen, not ready for anyone else’s servers yet.

01 — Why now

The bots never sleep.

Every server on the internet is being tried, all day, by machines. They don’t pick targets: they ask every address for the same mistakes. A copy of the source code left in /.git. A password file in /.env. An SSH login that still takes passwords. A patch that was published last week and never installed.

This site sees it too. On one recent day its access log held hundreds of requests for addresses that don’t exist, most of them bots fishing for files like /.git/config.

AI makes the attackers faster. It reads a new advisory, writes the exploit and tries it on every server it can reach, in hours instead of weeks. One forgotten setting is all it takes, and with several servers, something is always forgotten.

A person checks a server when there’s time. A script checks every server, every time.

That’s the idea behind server-kit: write down once what a correct server looks like, then let a program compare every server against it, as often as you like, and say plainly what’s wrong and how to fix it.

02 — Try it

Run a health check.

Pick a server and press Run. This is a replay of what composer server health reports, not a live server: every check, on one server at four moments in its life. The last one is a morning routine: health --list on every server, then the one that needs work.

~/my-site


        

03 — What it does

One command for each job.

composer server setup

Set a server up

From a fresh install: an admin user with key-only SSH and no root login, updates installed and automatic security updates on, fail2ban, a firewall that opens exactly the ports the server’s type needs, HTTPS, PHP and the app’s own user. It asks before each change, and running it again only fixes what’s missing.

composer server deploy

Deploy the project

The server pulls the branch from git, not from my laptop, so what goes up is what was pushed. Composer, migrations and caches follow; the front end is built on my computer from that same commit and uploaded, so Node never runs on the server. Secrets are made on the server and never printed or copied anywhere else.

composer server health

Check everything

Every check on every server, all servers at the same time: system, patches, security, software, web, the Laravel app, backups and scheduled jobs. It lists what passed too; --warn shows only the warnings and failures, and --list gives one line per server with how many checks passed, warned and failed, so an unhealthy server stands out at a glance. Exit code 1 when anything fails, so it can run from cron or CI.

composer server links

Every link works

Follows every link on the site the way a visitor would: each page in the sitemap, every page it links to, and the pictures and scripts it loads. Lists each broken link with the pages it’s on; --external checks links to other sites too.

composer server audit

Audit security

Just the security side: firewall rule by rule, SSH settings, fail2ban bans, automatic updates and pending patches.

composer server access

Never get locked out

Proves every key still gets in, with sudo, and keeps a backup key on every server, so losing one laptop doesn’t mean losing a server.

composer server alerts

Know who logs in

A message on my phone the moment someone logs in as root or admin, or a login fails.

composer server stats

See the traffic

Visitors, pages, referrers and 404s from the site’s own access log, read on the server. Nothing is sent to an outside analytics service.

composer server run

Do it everywhere

One command on every server, or on a tag like “web”, at the same time.

composer server info

Know what’s where

Each server’s site, commit, how far behind it is, its services and the ports its firewall opens.

04 — The attacker’s list

What the bots try, and the check that sees it first.

What an automated attacker triesThe checkWhat it makes sure of
Download /.env, /.git/config or the app’s logexposedNone of those files is served. It asks for them the way a bot would, from outside.
Guess SSH passwords, log in as rootssh · fail2banNo password login of any kind, no root login, and repeat offenders banned.
Use an exploit published last weekupdates · auto-updates · rebootSecurity updates install themselves, nothing is pending, and no patched kernel is waiting for a reboot.
Reach a database or admin port nobody meant to openfirewallEvery open port matches the server’s type, port by port and source by source, and SSH isn’t open to everyone.
Trigger an error page that shows the app’s secretsapp-envDebug mode is off, the app runs in production mode, and only the app can read its .env.
Log in with a stolen keylogin alerts · accessMy phone hears about it at once, and every key that can get in is one I know about.
Run on a system no longer patchedosUbuntu 26.04 or later. On anything older, setup stops before changing a thing.
Encrypt or delete the databackupsThe newest backup is recent and not empty.
Wait for a certificate to lapse, or a renewal to failcaddy · certificateA certificate with enough days left, and no failed renewals in the last day.

05 — How it’s built

Adds nothing to attack.

  • Plain SSH, from my machine. No agent on the servers, no dashboard on the internet, no new port to defend. A tool that watches servers shouldn’t become one more thing to break into.
  • Standards in the package, changes in the project. server-kit holds every standard in full: the kinds of server, the ports each service opens, the PHP extensions, the SSH rules, the health checks. The project’s own config holds only what it does differently, so a new check reaches every project with one composer update, and health reports every difference between a server and its standard.
  • Growing one kind of server at a time. Laravel behind Caddy today, for medium to heavy load websites. Laravel behind nginx for high-volume sites, and Python on a Raspberry Pi for sensors and file servers, are next. Every kind runs through the same tests, and setup won’t touch a server whose kind isn’t ready.
  • Careful with the one thing that can’t be undone. The firewall is never switched on unless the address I’m connecting from is allowed in, and if a fresh login fails right after, it’s switched off again. My own addresses are never banned by fail2ban, so a typo can’t lock me out.
  • Fast. All of a server’s checks run in one SSH session, and every server is checked at the same time.
  • Tested. An automated test suite covers the checks, the config and the commands, for every kind of server.

Write down what right looks like. Check it every time.