A fresh VPS is not quiet for long. You hit create, wait for the IP, and before you’ve even finished your first apt update , something out there is already trying your SSH port.
I’ve been doing cybersecurity and DFIR work for a long time, and I’ve been building and running servers even longer. Hardening a new box is one of those things I know I have to do every single time. I also got tired of doing it. So I built a tool. This post covers why hardening a Linux VPS matters, how I got annoyed enough to automate it, and how koncreet takes a brand new Debian or Ubuntu box from default to hardened in about a minute.
Why You Have to Harden a Linux VPS
A new VPS gets a public IP address, and the internet is full of scanners that never sleep. One person who put a fresh Ubuntu VPS online with nothing on it logged over 27,000 connection attempts from 99 unique IPs in the first 24 hours. A student running a honeypot for the SANS Internet Storm Center recorded more than 20 million SSH brute-force attempts over 100 days. Your server doesn’t have to be interesting. It just has to exist.
And the defaults aren’t built for that reality. Out of the box, most images accept password logins over SSH, let you log in as root, and have no firewall in front of anything you install later. That’s fine on a laptop behind a router. It isn’t fine on a public IP.
Here’s the part people underestimate. A compromised VPS is rarely about your data. Attackers want a clean machine with a good network connection: crypto miners, spam relays, scanning infrastructure, a hop to hide behind. In DFIR work, the pattern is familiar: a compromised box can sit unnoticed for a long time when nobody is looking at the logs. Hardening is how you make sure there’s something to look at, and fewer reasons to need it.
What Hardening Actually Means (The Essentials)
You can go down a very deep rabbit hole here. The Securing Debian manual is a good example of how deep it goes. But for a typical single VPS, the first hour comes down to a handful of things that give you most of the value:
- Stop logging in as root. Create a normal user with sudo and use that.
- Use SSH keys, not passwords. Then turn password authentication off. I wrote about this in Advanced Linux Security Measures.
- Default-deny firewall. Close everything, then open only what you actually serve.
ufwmakes this painless. - Ban brute-forcers. Fail2Ban won’t save a bad configuration, but it cuts the noise and the load. I covered the setup in How to Set Up Fail2Ban on Linux.
- Patch automatically. Security updates should install themselves. Plenty of compromises start with something known and unpatched.
- Tighten the kernel and keep your logs sane. A few network sysctl settings, accurate time, and logs that rotate instead of filling the disk. Good logs are worthless if the timestamps are wrong or the disk is full.
None of that is exotic. That’s the problem. It’s all simple, and it’s all tedious.
Where I Got Annoyed
I’ve written the guides. I know the steps. And I still didn’t want to do them by hand every time.
So I did what most of us do and scripted pieces of it. A snippet for the user, a snippet for sshd_config , a snippet for the firewall. It helped, but it never felt finished. I was still copying things around, still second-guessing myself, still holding my breath before restarting SSH because one typo means a locked-out server and a trip to the provider’s web console.
The details also bite you. Ubuntu and Debian handle unattended upgrades differently. Ubuntu 24.04 can start SSH through a socket unit, so the port isn’t where you expect it. Cloud images ship a 50-cloud-init.conf that can quietly override the SSH setting you just changed, because sshd keeps the first value it reads for a keyword. Each of those is solvable. None of them is something I want to rediscover on every new box.
The other thing is how I deploy. Most of the time I’m standing up a single VPS, not a fleet, and the tooling built for rolling out lots of servers at once is overkill for that. For one box at a time, I wanted something I could run, read, and preview before it touched anything.
That made building it the obvious move.
Meet koncreet
koncreet is first-hour hardening for a fresh Linux VPS. It’s plain Bash, it shows you a plan before it changes anything, and its defaults are built to avoid locking you out. It supports Debian 12/13 and Ubuntu 22.04/24.04.
It’s split into five modules:
- baseline: creates a sudo user and installs your SSH keys, writes sysctl hardening settings, adds a swapfile if the box has none, caps the journal at 200 MB, sets up log rotation, and makes sure time sync is running.
- firewall:
ufwwith default-deny incoming. It detects your real SSH port first so it never enables the firewall without allowing you in. It refuses to continue if it can’t find the port. - fail2ban: uses the systemd backend and hooks into
ufwfor bans when the firewall is active. It also offers to whitelist your current IP so you don’t ban yourself on your first typo. - updates: unattended security updates with the right origins for your distro. Automatic reboots are off unless you ask for them.
- ssh: turns off password login, root login, and keyboard-interactive auth, with a few sane connection limits.
Install is one line:
curl -fsSL https://github.com/jimididit/koncreet/releases/latest/download/install.sh | sudo bash
Yes, I know. Piping a script to a shell on a security blog. If that makes you twitch, good. Read install.sh first, pin a release with KONCREET_VERSION=0.2.5 , or just clone the repo and run it from there. All three work.
Then:
sudo koncreet doctor sudo koncreet
doctor checks whether the box is ready. Running koncreet with no arguments gives you an interactive menu, including a “run everything” option. If you’d rather keep it in a file, there’s a config-driven mode:
sudo koncreet --dry-run apply -c ./koncreet.conf sudo koncreet apply -c ./koncreet.conf --yes
The first command prints the plan and changes nothing. The second does the work.
The Part I Care About Most: Not Locking Myself Out
Hardening scripts are dangerous in a specific way. The most common failure isn’t a hack, it’s the admin who disabled password login before the key worked. So most of the effort in koncreet went into safety rails:
- Dry-run first.
--dry-runshows what would change and writes nothing. - SSH hardening has a gate. It only runs if a non-root sudo user with SSH keys already exists. On a fresh box where
baselinejust created that user, koncreet plans a skip for SSH, tells you so, and leaves a warning in the login message until it’s done. You log in as the new user, confirmsudo -vworks, then runsudo koncreet ssh apply. - It verifies the result. After writing its SSH drop-in, koncreet checks the effective configuration with
sshd -T, includingMatchblocks that can sneakily re-enable passwords. If anything overrides it, it rolls back and shows you the offending lines. The drop-in is named00-koncreet.confso it wins over50-cloud-init.conf. - Everything has an undo.
sudo koncreet ssh undo,baseline undo,fail2ban undo, andfirewall undoall exist. There are also commands for unbanning an IP, and the README has a troubleshooting table for the lockout scenarios I could think of. - It’s tested against the failure cases. CI runs integration scenarios against a real sshd, sudo, and
ufwon Debian and Ubuntu containers, because a lockout bug is the worst kind of bug for a tool like this.
Because koncreet is open source, it has already had help from the community, and that’s exactly why I wanted it that way. Contributions are welcome.
From Creation to Hardened in 60 Seconds
This is where it comes together. I wanted to show the real workflow, so I recorded it. I used gmab (Give Me A Box), a CLI for spawning temporary cloud boxes, to spin up a fresh Debian VPS. Then I installed koncreet and ran it.
The flow is simple: spawn the box, SSH in, install koncreet, apply. From nothing to a hardened server took about 60 seconds. That’s including the box existing.
You can watch the whole thing on my Instagram at instagram.com/jimi.did.it. It’s my most recent Reel.
That’s what I wanted: a new server goes from default to defensible before I’ve had time to get distracted. And because of the SSH gate, the one step I deliberately don’t rush is the last one. I’d rather take ten extra seconds proving my key login works than gamble on it.
What koncreet Doesn’t Do
I want to be straight about scope, because a hardening tool that overpromises is its own kind of risk.
- It is not a CIS or STIG benchmark tool.
- It is not fleet management. If you’re deploying dozens of servers, you want something built for that.
- It doesn’t harden your applications, set up backups, or ship your logs somewhere safe.
- It won’t open databases or FTP to the whole internet unless you explicitly pass
--public.
Think of it as the first hour. What you run on the server after that is still your job. Keep patching, watch your logs, back things up, and don’t expose services you don’t need.
Try It
If you spin up VPS boxes by hand and have felt the same annoyance I did, give it a run. Start with doctor and a --dry-run so you can see exactly what it plans to do. The code is MIT licensed at github.com/jimididit/koncreet. If it breaks on your setup or you spot a gap, open an issue or a pull request.
TL;DR
- A fresh VPS is scanned within hours. Defaults aren’t enough.
- The essentials: non-root sudo user, SSH keys only, default-deny firewall, Fail2Ban, automatic security updates, sane kernel and log settings.
- Doing it by hand every time is tedious and risky, mostly because of lockouts.
- koncreet automates those essentials for Debian and Ubuntu, previews changes first, and builds in lockout protection and undo.
- It’s not a compliance tool. It’s the first hour, done right.
FAQs
Why do I need to harden a new Linux VPS?
A new VPS gets a public IP and automated scanners find it fast. Default settings on most images allow password logins and have no firewall, so hardening closes the easy doors before someone walks through them.
What does koncreet do?
It’s a Bash tool for Debian 12/13 and Ubuntu 22.04/24.04. It creates a sudo user with SSH keys, applies safe sysctl settings, enables a ufw default-deny firewall, sets up Fail2Ban, turns on unattended security updates, and disables SSH password and root login once it’s safe to do so.
Can koncreet lock me out of my server?
It’s built to avoid that. It only disables SSH password and root login if a non-root sudo user with keys already exists, it verifies the result with sshd -T and rolls back on failure, and every module has an undo command. Still, keep your current session open and test a new login before you disconnect.
Is koncreet a replacement for CIS or STIG hardening?
No. It covers the essential first-hour steps for a single VPS. If you need compliance benchmarks or fleet-wide enforcement, use tools built for that.
If you found this helpful, you’ll love the rest of my blog at An Experienced Developer’s Experiences. Harden responsibly, folks. See you there!
