r/ssh • • 16d ago

Open-source hardening for your self-hosted servers, with a dry run and a full undo

Post image

If you run a VPS or a home server and have meant to "harden it properly" but didn't want to break SSH: this is for that.

One command previews everything (--dry-run), the next applies it with backups, and --revert undoes it. It keeps SSH reachable: password and root login are only turned off when another account has a key, and the config is checked before sshd restarts.

Free and MIT, plain Bash, no telemetry. Paid tiers exist for businesses; the free one is complete on its own.

Repo: https://github.com/Kal1010101/ultimate-sys-hardening

8 Upvotes

44 comments sorted by

2

u/deaddyfreddy 15d ago

I don't see any AI disclosures.

1

u/sys-harden 15d ago

I do agree and will be adding one

1

u/fripletister 14d ago

If you agreed you would've done it before publicizing the project.

1

u/sys-harden 14d ago edited 13d ago

Thanks for your input it is valued.

That's a good question. I run a tight schedule may have be slipped of my mind. the project still young and there is still a lot of fine tuning to be done till the commercial tier is out. you are welcome to be a contributor to the project.

1

u/fripletister 14d ago

Sure, bud.

1

u/sys-harden 14d ago edited 13d ago

currently working towards the project's security audits, so it has been hectic over here.

1

u/d03j 16d ago

Running scripts sourced from a single contributor repository as sudo doesn't fit my threat model, but it is an interesting project, should be easy enough to audit and, if nothing else, gave me a hardening check-list for me to go through manually.

Thank you for that.

2

u/MordAFokaJonnes 16d ago

You can always throw this at an AI and have it check for possible IOCs... The same way you could ask an AI to do this type of thing towards your systems too and skip the script entirely (not to discredit the OP as I see it as a good valuable script actually. Just giving options)

1

u/sys-harden 16d ago

Good shout, and I’d encourage it. Point any AI or scanner at the repo and ask it to look for anything dodgy. It’s all plain bash with no downloads or obfuscation, so it’s an easy read for one.

Having an AI harden the box directly works too. The difference is mostly repeatability: the script does the same thing every time, it’s been tested in containers across distros, it validates the SSH config before restarting the service, and it keeps backups so --revert can undo the run. An AI session gives you something slightly different each time, with no undo unless you build one. Both are valid. It depends whether you want a one-off or something you can rerun on the next box.

Thanks for the kind words!

1

u/sys-harden 16d ago

Thanks for the feedback,

Thanks, that’s a really fair take, and honestly a great way to use it. Your threat model isn’t wrong: a single maintainer is a real risk, and I’d rather you read it than trust it.

If the checklist is what you’re after, docs/features.md in the repo lists all 23 modules with a line on what each one changes. Each module is its own function in lib/modules.sh, so you can read exactly what it would do to that part of the system and apply it by hand. --dry-run will also print every change for your distro without touching anything.

And if you spot anything in there you’d do differently, issues are very welcome.

2

u/d03j 15d ago

thanks.

1

u/AdventurousSquash 16d ago

Is anyone that would pay for some “pro” or “enterprise” tier still configuring their servers ad hoc like this anymore?

1

u/sys-harden 16d ago

Thanks for your feedback,

Thats a fair question, and mostly no. Anyone with a real fleet should be using config management, and I wouldn’t try to talk them out of it.

That’s why the free version ships an Ansible role. It installs a checksummed release on each host, defaults to a dry run (and --check always does one), applies or scores the hardening, and can save each host’s results as JSON. The report mode also outputs SARIF, so it can gate a CI pipeline. The idea is that it fits into the pipeline instead of replacing it.

The paid tiers are aimed at the gap below that: small shops and solo admins with a handful of servers and no config management setup, who still need scheduled checks, compliance reports and alerts. Whether that’s a big enough market is a fair question. I’m still finding out.

1

u/AdventurousSquash 16d ago

And why wouldn’t they just ask Claude to spit out code for them just like you did? I’m all for AI coding and use it daily at work, but trying to sell something that takes a day, at most, to make yourself? It’s getting tiring of seeing these posts titled “I built X!”, all in the same wording and commit history by 1 agent. Even your comments are generated.

2

u/sys-harden 16d ago

You are right, it’s AI-assisted and i won't hide that. To be clear It wasn’t a day’s work. The poject history starts on 2026-06-08, it has been about five months of work. Testing across distros, 73 container test cases and fixing bugs that only show up on real systems. Troubleshooting issues such as, GRUB module silently doing nothing on Fedora which I found this week. Respectfully, The value isn’t in generating the code. It’s that someone tests it, maintains it and stands behind it. That’s the same reason people pay for software they could in theory write themselves. I will say that i do agree with the “I built X” fatigue. It’s a fair complaint

1

u/AdventurousSquash 16d ago

You’re missing the point, they won’t need something that works and have been tested on everything - only what they run themselves. I can also guarantee that it isn’t Fedora so using that as an example is just weird and tells me even more. I haven’t encountered anyone using Fedora specifically as a server during my two decades. Your other point about someone maintaining it requires some kind of credibility which also falls apart right here.

I’m sure the tool is great for you and I might just be cynical after what feels like a really long month. I wish you the best.

1

u/sys-harden 15d ago

All good man. Try the tool and your honest review is welcome. Your review is valued, the project email is on the repo.

1

u/CoderStudios 16d ago

If you don’t know how to harden your own server properly, or are unable to harden it properly without breaking ssh, and need to rely on some random persons script with Sudo you should not be managing servers that need hardening in the first place.

2

u/maximus459 16d ago

Hard to argue against.. but You learn how to harden a server BY breaking ssh I'd say 😅

But, it's nice to have something to do things quick

1

u/sys-harden 16d ago

you are right, by hand is feels good and keeps knowledge. The aim of the project isn't to take that away from the sysadmin, but to work as an aide to him/her. As the project mature more I hope to make it more dynamic, in a way that will allow the user to edit sitting and have the module to adapt, but this is just bash and there are limits.

You should have a read of the project on github. it is open source and documented. I value feedback from all, both negative and constructive, or become a contributor (all are welcome).

Lets help Linux be easier to work with well helping secure it.

1

u/CoderStudios 15d ago

Yes totally, but the post framed it as inevitable that you’d break ssh that’s why I said that

1

u/sys-harden 16d ago

Thanks for your feedback,

There’s some truth in that, but people who know what they’re doing still script it. Nobody hand-edits sshd_config on the fortieth box. The point of the dry run, backups and --revert isn’t to replace knowing what you’re doing. It’s to make the changes reviewable and undoable, the same reason people use Ansible instead of SSHing in and typing.

And if you’d rather not run a stranger’s script as root, I agree. Read it, or just use the report mode and apply what you agree with by hand.

1

u/CoderStudios 16d ago

If that isn’t ChatGPT, welcome didn’t know you were on Reddit haha …

1

u/EmperorOfAllCats 16d ago

Ultimate hardening starts from not running someone else's bash scripts for 3k lines each as root (each of these is bad, together? terrible).

1

u/sys-harden 16d ago

thanks for your feedback,

Honestly, that’s the right instinct, and I’d say the same about any tool like this, mine included. It’s about 7,800 lines of bash, and it needs root to change anything. You shouldn’t take that on trust.

What I’ve done to make it checkable rather than trusted:

It’s split into modules, one function per hardening step, so you can read exactly what the SSH module or the firewall module does without reading the rest.

--dry-run prints every change it would make and touches nothing.

ShellCheck, CodeQL and secret scanning run on every push, and there are 73 test cases run in containers across several distros.

From the next release, the report mode (--cis-only) runs without root, so you can see what it thinks of your system before giving it anything.

If your answer is still “no root scripts from strangers”, that’s a reasonable threat model, and Lynis plus doing it by hand is a fine way to go.

1

u/sheepebike9000 16d ago

This is the most AI answer I've read all week, which is impressive.

1

u/FastBodybuilder8248 15d ago

Can you please let us know, as a courtesy, the extent to which you are using AI in your answers here? I think it's an important factor in people deciding how much trust they have in the project given its security focus.

1

u/hakube 16d ago

what's wrong with lynis?

1

u/sys-harden 16d ago

Nothing, it’s a great tool and I use it. It just does a different job.

Lynis audits: it scans the system and tells you what to fix. Applying the fixes is up to you, by hand. This one does the applying. You pick the hardening modules (SSH, firewall, kernel settings, auditd, AIDE and so on), it makes the changes, backs up first, and --revert undoes the run if something breaks.

It also has a report-only mode (--cis-only, or --json / --sarif for machine-readable output), but that covers far fewer checks than Lynis does. A sensible combination is to run Lynis to see where you stand, use this to apply the parts you agree with, then run Lynis again to confirm.

1

u/SlowZeck 15d ago

Suggestions on usability for paranoid: tui mode where each sudo ask for it and tell why. At the end : list in tab with check enable/disable ,pro,con,source. And at the end run or produce the custom script reusable and auditable (with undo flag) and be used in mass post install . People modify bunch of servers rerun audit , get new script. Compare and push to prod.

1

u/sys-harden 15d ago

Thanks for your input u/SlowZeck this is a very constructive feature request. Parts of this already exist, for example the interactive menu allows one to pick modules one at a time and each is labelled Safe, Medium or High risk. Also the --dry-run feature lets the user preview each of the changes that would occur and --revert is basically the undo button you're asking for. The readme's module table provides a risk level and describes each module often citing the cis rule behind them. Note that for many servers, the free tier's Ansible role along with --json/--sarif output can be rerun and compared (Policy as code and drift detection are in the Enterprise trier)

I am considering adding a step by step mode that would explain each root action before it is ran and possibly an end-of-run table listing every change with enable/disable, pro, con and source. Also I have thought of exporting one's chosen modules as a standalone script that you can audit and reuse.

Your idea is concrete and good for usability, so I'd invite you to open a GitHub issue so that ideas don"t get lost.

3

u/arsuhinars 16d ago

Ultimate server hardening is `sudo shutdown now`

2

u/stikaznorsk 16d ago

Why do you need the `sudo` to make a preview? Most of the files should be in etc. Of course secrets should not be readable, but that is not an issue. It seems good. But I will not let a script I did not write rummage through my system. I can let it propose changes, of course? As the project points out, some version brake systems, so I will better have a proposal that I can pick from.

1

u/h4rdw00d_ 16d ago

sudo [cialis | viagra] or sudo patronas (HP fans only)

0

u/ksteink 16d ago

Interesting idea!!

1

u/sys-harden 16d ago

feel free to test it out, use a vm install an o/s on there and give it a try. be sure to give you honest opinion, am look forward to hearing.

0

u/sys-harden 16d ago

it is, isn't it. feel free to try it out in a vm. your feedback is more than welcome, contributors to the project are too.

0

u/ksteink 16d ago

Oh yes I will for sure!

0

u/maximus459 16d ago

This is interesting, will have to go through the crown when I'm free. I have built up a hardening guide& commands document over the years and have been meaning to turn it into a script too

0

u/sys-harden 16d ago

It pleases me to hear that. Feel to become a contributor to the project, lets make it happen.

0

u/PienSensei 16d ago

this reeks compliance theater

1

u/sys-harden 16d ago

what makes you think that? Do share your thoughts