I, recently, started running a Lemmy instance. I am, also, new to Linux servers.

At the advisement of some tech acquaintances, I’ve installed UnnattendedUpgrades and Fail2ban.

What would you recommend?

  • gofoss.net@lemmy.ml
    link
    fedilink
    arrow-up
    10
    ·
    3 years ago

    Below a couple of ideas, some building on what has already been stated. It’s all detailed here:

    Feedback really welcomed, as there’s always something to be learned in server security :)

    General hardening:

    • set up a firewall (ufw)
    • make sure your system time is correct (ntp)
    • enable unattended upgrades
    • limit privileged access (sudo)
    • hide process information (/proc)
    • enforce strict password policy (pam, login.defs)
    • enforce stricter permissions (umask)
    • close all unused ports (check with nmap)
    • install a malware scanner (lmd)
    • install an antivirus (clamav)
    • disable core dumps
    • disable unused kernel modules
    • add legal banner

    SSH:

    • change the port
    • limit the nb of login attempts
    • limit access to admin users
    • enable access logs
    • forbid remote access to root
    • use auth keys with instead of password auth
    • disconnect after inactivity period
    • remove short encryption keys

    MySQL (if applicable):

    • run a hardening script
    • disable remote access
    • prevent unauthorised access to local files
    • create separate users with limited privileges for each app

    Apache (if applicable):

    • enable security modules
    • hide http headers
    • set up modsecurity, a web app firewall

    PHP (if applicable):

    • hide php version in headers
    • disable remote code execution
    • disable potentially harmful functions
    • limit script runtime & memory allocation

    Network security (sysctl):

    • ip spoofing protection
    • ignore icmp broadcasts & redirects
    • disable source paket routing
    • block syn attacks
    • log martians
    • ignore pings
      • krolden@lemmy.ml
        link
        fedilink
        arrow-up
        6
        ·
        edit-2
        3 years ago

        Not really. Especially the antivirus. Its pretty easy to avoid such things by not installing any untrusted aoftware. Not to mentionitf youd likely be ransomwared before you detectedanhthing.

        But hosting publicly facing services is always a risk.

  • seahorse [Ohio]@midwest.social
    link
    fedilink
    arrow-up
    6
    ·
    3 years ago

    The linux upskill challenge guides users through setting up a server from the beginning and shows you how to set up a firewall with ufw as well as disabling root login via ssh.

    • krolden@lemmy.ml
      link
      fedilink
      arrow-up
      4
      ·
      3 years ago

      Also try to set it up without installing sudo , which will eliminate a lot of privilege escalationvulnerabilities.

  • smorks@lemmy.ca
    link
    fedilink
    arrow-up
    4
    ·
    3 years ago

    disable root login over ssh, and use public keys auth if possible.

    fail2ban is good, but needs to be configured properly.

    there’s probably lots more, but that’s a start.

      • smorks@lemmy.ca
        link
        fedilink
        arrow-up
        3
        arrow-down
        1
        ·
        3 years ago

        to be clear, the only way to access ssh is by connecting through the VPN? yeah, it should be fine, as long as your vpn is secure.

    • suspended@lemmy.mlOP
      link
      fedilink
      arrow-up
      1
      ·
      3 years ago

      fail2ban is good, but needs to be configured properly.

      Thank you for responding kindly. Is there a resource that you’d recommend looking into proper configuration?

      • smorks@lemmy.ca
        link
        fedilink
        arrow-up
        2
        ·
        3 years ago

        I think their doc’s are decent? and I could be wrong, and maybe it depends on the Linux distribution, but I’m just not 100% sure if it actually does anything without some basic configuration.