I’m working on a guide focused on securing Linux servers and I’d like to ask you what your essential hardening techniques and tips are? Your feedback would be greatly appreciated
Change SSH to only allow certificates not passwords.
Submitted 1 year ago by wop@infosec.pub to cybersecurity@infosec.pub
I’m working on a guide focused on securing Linux servers and I’d like to ask you what your essential hardening techniques and tips are? Your feedback would be greatly appreciated
Change SSH to only allow certificates not passwords.
For personal homelab, I keep it really simple, and I try to think realistically. Which means, using keys with ssh, setting up ufw and keep as little exposure for ports as possible, fail2ban, only really using user accounts with sudo instead of root, use containers and vms when I can to help keep things contained if I am working on something that might have links or files that are malicious, run something like a PiHole or AdGuard Home, etc.
I do plan on adding pfsense + security onion once I can get the proper hardware that has enough ram, but this is probably the only “overkill” I plan on running.
For stuff like VPS usually just UFW + SSH keys is mostly what I need, but add as I needed.
If I ever end up as a Linux Sysadmin, I would use a much more robust and proper setup for the company which means something like grsec, try to do something like setup a much better EDR/SIEM, rotate ssh keys if possible, etc.
CIS benchmarks have a guide for most enterprise distros.
There is no one way to secure Linux servers because Linux isn’t one thing due to distribution sprawl. How you do things depends on the distribution. If you want a general guide the CIS Benchmarks are a decent place to start. Then you can make a guide on how to implement them with your target Linux server distribution. Keep in mind this is for the OS and application hardening is just as important, and is an entirely different can of worms. downloads.cisecurity.org/#/
The CIS benchmarks for Linux are a good start. There are some off the shelf tools that let you run those, notably linux-bench. Another tool in a similar fashion is lynis. You can also use eBPF tools like callander to examine your workload behaviour and help tighten your seccomp policies.
Once you’ve established a baseline for your system, you’ll next want to harden your environment. This means network scans, OWASP, etc. As far as off the shelf tools go, OpenVAS is quite popular even in Enterprise environments.
Finally there’s the continuous security tasks. Continuous package updates, runtime security, log analysis, etc. There are some free tools that cover part of this like Security Onion, but if the price is right a SaaS tool can save you a lot of time.
Hardening depends on your threat model and needs of the client. Have the system do what it is supposed to do nothing more or less. I pretty much use this as a guide line depending on client needs.
Not a full list, just some ideas for personal servers.
Please be aware that the requirements in a business environment might be different.
demesisx@infosec.pub 1 year ago
Here’s how this concept made it into my radar. This is an obsessively paranoid NixOS config and accompanying article:
xeiaso.net/blog/paranoid-nixos-2021-07-18/
Also, for further reference:
There’s a whole subsection of nixpkgs that could be helpful for a gardening guide:
github.com/NixOS/nixpkgs/blob/…/hardened.nix
Also, there are a few articles walking us through hardening Nix:
dataswamp.org/…/2022-01-13-nixos-hardened.html
On NixOS Discourse:
discourse.nixos.org/t/…/6