this post was submitted on 10 Feb 2025
734 points (99.3% liked)

linuxmemes

22397 readers
2871 users here now

Hint: :q!


Sister communities:


Community rules (click to expand)

1. Follow the site-wide rules

2. Be civil
  • Understand the difference between a joke and an insult.
  • Do not harrass or attack users for any reason. This includes using blanket terms, like "every user of thing".
  • Don't get baited into back-and-forth insults. We are not animals.
  • Leave remarks of "peasantry" to the PCMR community. If you dislike an OS/service/application, attack the thing you dislike, not the individuals who use it. Some people may not have a choice.
  • Bigotry will not be tolerated.
  • These rules are somewhat loosened when the subject is a public figure. Still, do not attack their person or incite harrassment.
  • 3. Post Linux-related content
  • Including Unix and BSD.
  • Non-Linux content is acceptable as long as it makes a reference to Linux. For example, the poorly made mockery of sudo in Windows.
  • No porn. Even if you watch it on a Linux machine.
  • 4. No recent reposts
  • Everybody uses Arch btw, can't quit Vim, <loves/tolerates/hates> systemd, and wants to interject for a moment. You can stop now.
  • 5. ๐Ÿ‡ฌ๐Ÿ‡ง Language/ัะทั‹ะบ/Sprache
  • This is primarily an English-speaking community. ๐Ÿ‡ฌ๐Ÿ‡ง๐Ÿ‡ฆ๐Ÿ‡บ๐Ÿ‡บ๐Ÿ‡ธ
  • Comments written in other languages are allowed.
  • The substance of a post should be comprehensible for people who only speak English.
  • Titles and post bodies written in other languages will be allowed, but only as long as the above rule is observed.
  • ย 

    Please report posts and comments that break these rules!


    Important: never execute code or follow advice that you don't understand or can't verify, especially here. The word of the day is credibility. This is a meme community -- even the most helpful comments might just be shitposts that can damage your system. Be aware, be smart, don't remove France.

    founded 2 years ago
    MODERATORS
     

    Background: 15 years of experience in software and apparently spoiled because it was already set up correctly.

    Been practicing doing my own servers, published a test site and 24 hours later, root was compromised.

    Rolled back to the backup before I made it public and now I have a security checklist.

    you are viewing a single comment's thread
    view the rest of the comments
    [โ€“] DaCrazyJamez@sh.itjust.works 30 points 16 hours ago (2 children)

    As a linux n00b who just recently took the plunge and set up a public site (tho really just for my own / selfhosting),

    Can anyone recommend a good guide or starting place for how to harden the setup? Im running mint on my former gaming rig, site is set up LAMP

    [โ€“] psivchaz@reddthat.com 26 points 14 hours ago (1 children)

    The other poster gave you a lot. If that's too much at once, the really low hanging fruit you want to start with is:

    • Choose an active, secure distro. There's a lot of flavors of Linux out there and they can be fun to try but if you're putting something up publicly it should be running on one that's well maintained and known for security. CentOS and Debian are excellent easy choices for example.

    • Similarly, pick well maintained software with a track record. Nginx and Apache have been around forever and have excellent track records, for example, both for being secure and fixing flaws quickly.

    • If you use Docker, once again keep an eye out for things that are actively maintained. If you decide to use Nginx, there will be five million containers to choose from. DockerHub gives you the tools to make this determination: Download number is a decent proxy for "how many people are using this" and the list of updates tells you how often and how recently it's being updated.

    • Finally, definitely do look at the other poster's notes about SSH. 5 seconds after you put up an SSH server, you'll be getting hit with rogue login attempts.

    • Definitely get a password manager, and it's not just one password per server but one password per service. Your login password to the computer is different from your login to any other things your server is running.

    The rest requires research, but these steps will protect you from the most common threats pretty effectively. The world is full of bots poking at every service they can find, so keeping them out is crucial. You won't be protected from a dedicated, knowledgeable attacker until you do the rest of what the other poster said, and then some, so try not to make too many enemies.

    [โ€“] horse_battery_staple@lemmy.world 5 points 13 hours ago* (last edited 13 hours ago)

    The TLDR is here : https://www.digitalocean.com/community/tutorials/recommended-security-measures-to-protect-your-servers

    You wonโ€™t be protected from a dedicated, knowledgeable attacker until you do the rest of what the other poster said, and then some,

    You're right I didn't even get to ACME and PKI or TOTP

    https://letsencrypt.org/getting-started/

    https://openbao.org/docs/secrets/pki/

    https://openbao.org/docs/secrets/totp/

    And for bonus points build your own certificate authority to sign it all.

    https://smallstep.com/blog/build-a-tiny-ca-with-raspberry-pi-yubikey/

    [โ€“] horse_battery_staple@lemmy.world 19 points 15 hours ago* (last edited 14 hours ago) (1 children)

    Paranoid external security. I'm assuming you already have a domain name. I'm also assuming you have some ICANN anonymization setup.

    This is your local reverse Proxy. You can manage all this with a container called nginx proxy manager, but it could benefit you to know it's inner workings first. https://www.howtogeek.com/devops/what-is-a-reverse-proxy-and-how-does-it-work/

    https://cloud9sc.com/nginx-proxy-manager-hardening/

    https://github.com/NginxProxyManager/nginx-proxy-manager

    Next you'll want to proxy your IP address as you don't want that pointing to your home address

    https://developers.cloudflare.com/learning-paths/get-started-free/onboarding/proxy-dns-records/

    Remote access is next. I would suggest setting up wireguard on a machine that's not your webserver, but you can also set that up in a container as well. Either way you'll need to punch another hole in your router to point to your wire guard bastion host on your local network. It has many clients for windows and linux and android and IOS

    https://github.com/angristan/wireguard-install

    https://www.wireguard.com/quickstart/

    https://github.com/linuxserver/docker-wireguard

    Now internally, I'm assuming you're using Linux. In that case I'd suggest securing your ssh on all machines that you log into. On the machines you're running you should also install fail2ban, UFW, git, and some monitoring if you have the overhead but the monitoring part is outside of the purview of this comment. If you're using UFW your very first command should be sudo ufw allow ssh

    https://www.howtogeek.com/443156/the-best-ways-to-secure-your-ssh-server/

    https://github.com/fail2ban/fail2ban

    https://www.digitalocean.com/community/tutorials/ufw-essentials-common-firewall-rules-and-commands

    Now for securing internal linux harden the kernel and remove root user. If you do this you should have a password manager setup. keepassx or bitwarden are ones I like. If those suck I'm sure someone will suggest something better. The password manager will have the root password for all of your Linux machines and they should be different passwords.

    https://www.makeuseof.com/ways-improve-linux-user-account-security/

    https://bitwarden.com/help/self-host-an-organization/

    https://keepass.info/

    Finally you can harden the kernel

    https://codezup.com/the-ultimate-guide-to-hardening-your-linux-system-with-kernel-parameters/

    TLDR: it takes research but a good place to start is here

    https://www.digitalocean.com/community/tutorials/recommended-security-measures-to-protect-your-servers

    [โ€“] psivchaz@reddthat.com 9 points 14 hours ago (1 children)

    Correct, horse battery staple.

    [โ€“] horse_battery_staple@lemmy.world 5 points 14 hours ago* (last edited 14 hours ago)

    I couldnโ€™t justify putting correct in my username on Lemmy. But I loved the reference too much not to use it, so here I am, a less secure truncated version of a better password.