this post was submitted on 20 Apr 2024
137 points (99.3% liked)

Selfhosted

40133 readers
579 users here now

A place to share alternatives to popular online services that can be self-hosted without giving up privacy or locking you into a service you don't control.

Rules:

  1. Be civil: we're here to support and learn from one another. Insults won't be tolerated. Flame wars are frowned upon.

  2. No spam posting.

  3. Posts have to be centered around self-hosting. There are other communities for discussing hardware or home computing. If it's not obvious why your post topic revolves around selfhosting, please include details to make it clear.

  4. Don't duplicate the full text of your blog or github here. Just post the link for folks to click.

  5. Submission headline should match the article title (don’t cherry-pick information from the title to fit your agenda).

  6. No trolling.

Resources:

Any issues on the community? Report it using the report flag.

Questions? DM the mods!

founded 1 year ago
MODERATORS
top 50 comments
sorted by: hot top controversial new old
[–] [email protected] 1 points 4 months ago

Use a hardened-by-default OS like OpenBSD, HardenedBSD, or something similar in Linux.

[–] [email protected] 3 points 6 months ago

Air gapping

/s

[–] [email protected] 6 points 6 months ago

Ask yourself a few questions first before following the massive amount of suggestions and then locking yourself out and so on.

  • What are you worried about ?
  • How important is your stuff ?
  • Make backups and check them

Still worried ? Then there's the easy way out : Hire some security auditor to help you find holes you left.

[–] [email protected] 3 points 6 months ago

Stumbled uppon this guide

https://github.com/imthenachoman/How-To-Secure-A-Linux-Server

I think its a good place to start

[–] [email protected] 4 points 6 months ago

Do a search for you server OS + STIG

Then, for each service you're hosting on that server, do a search for:

Service/Program name + STIG/Benchmark

There's tons of work already done by the vendors in conjunction with the DoD (and CIS) to create lists of potential vulnerable settings that can be corrected before deploying the server.

Along with this, you can usually find scripts and/or Ansible playbooks that will do most of the hardening for you. Though it's a good Idea to understand what you do and do not need done.

[–] [email protected] 0 points 6 months ago
[–] [email protected] 2 points 6 months ago

Run SCAP tool with a STIG baseline.

[–] [email protected] 8 points 6 months ago

Check out online resources such as the Nist cyber stuff.

Basic things include disabling unnecessary services, disabling password authentication, setting up and verifying the firewall, configuring selinux and so on.

[–] [email protected] 19 points 6 months ago (2 children)

Don't turn it on is the ultimate technique

[–] [email protected] 1 points 6 months ago

barring that, unplug the ethernet.

[–] [email protected] 3 points 6 months ago

That's why "availability" is a core tenet of security (according to some cybersecurity course I took). It is easy to prevent unauthorized access to data if you have no requirements on authorized access.

[–] [email protected] 2 points 6 months ago (2 children)

Ubuntu has a set of scripts you can run to harden a new server (not advisable on a server that has already been configured for something). You need an Ubuntu Pro subscription to access them but you can get a free trial and then cancel it after you've finished.

More info at https://ubuntu.com/security/cis.

I did this process for a customer recently and it was pretty straightforward and much much more thorough (over 100 configuration changes) than just tweaking SSH and fail2ban.

I expect other commercially-oriented distros offer something similar.

[–] [email protected] 1 points 6 months ago

Fwiw you don't need to cancel or trial anything. Everyone can get free Ubuntu pro licensesbfor up to 5 machines

[–] [email protected] 3 points 6 months ago

Leak the scripts?

[–] [email protected] 6 points 6 months ago (1 children)

I like to require access to 22 via IP whitelist and all services on SSL behind a reverse proxy. Doesn’t leave much surface to attack.

[–] [email protected] 5 points 6 months ago (1 children)

Also, move ssh to a different, higher port. Since ssh isn't exactly for noobs, changing the port is easy enough to work with and that alone already reduces port scans and what not

[–] [email protected] 2 points 6 months ago

I recently setup Guacamole (Web based VNC/RDP/SSH) with totp and was able to close external SSH access. Now everything I run can sit behind a single reverse proxy, no extra ports.

[–] [email protected] 21 points 6 months ago* (last edited 6 months ago) (1 children)
  • fail2ban / brute forcing prevention
  • quick, frequent updates(!)
  • containerization / virtualization
  • secure passwords, better keys
  • firewall
  • a hardened operating system (distribution)
  • SELinux / Apparmor / ... / OpenBSD
  • not installing unnecessary stuff
  • An admin who is an expert and knows what they do.
[–] [email protected] 3 points 6 months ago

Me, two+ decades into tinkering and still a dumbass: "look at me, I'm the expert admin now"

[–] [email protected] 12 points 6 months ago (1 children)
  • crowdsec
  • SSH - change port, disable root login, disable password login, setup SSH keys using SK(YubiKey in my case)
  • nftables - I use https://github.com/etkaar/nftm to keep things quick and simple. I like the fact if will convert DNS entries to IPs. I then just use dynamic DNS update clients on all my endpoints
  • WireGuard for access to services other than SSH(in some cases port 443 will be open if its a web server or proxy)
  • rsyslog to forward auth logs to my central syslog server
[–] [email protected] 3 points 6 months ago (1 children)

disable root login

That does not do much in practice. When a user is compromised a simple alias put in the .bashrc can compromise the sudo password.

Explicitly limit the user accounts that can login so that accidentally no test or service account with temporary credentials can login via ssh is the better recommendation.

[–] [email protected] 8 points 6 months ago (1 children)

I think the point is that root is a universal user found on all linux systems where as users have all kinds of names. It narrows down the variables to brute-force, so simply removing the ability to use it means they have to guess a username and a password.

[–] [email protected] 3 points 6 months ago (1 children)

guess a username and a password.

Security by obscurity is no security. Use something like fail2ban to prevent brute force. When you use a secure password and or key this also does not matter much.

[–] [email protected] 2 points 6 months ago

Something something don't let 'good' be the enemy of 'perfect'

load more comments
view more: next ›