When you spin up a fresh public Linux instance, automated scanners start knocking on your doors within milliseconds.

It doesn’t take much to get locked down properly, but missing a few basics can leave you exposed.

I’ve put together a straightforward guide covering the essential hardening steps from UFW and SSH key-only auth to secure Docker bindings and automated maintenance.


Original content by The Unknown Universe, written by a human and not AI generated!

  • mlg@lemmy.world
    link
    fedilink
    English
    arrow-up
    18
    arrow-down
    1
    ·
    6 days ago

    I’ll have to find the post again (it was somewhere here on Lemmy) but UFW does not apply to docker containers.

    Docker bypasses UFW because it uses iptables and UFW doesn’t support firewall zones.

    Any docker/podman ports not bound to localhost will be publicly accessible even if you have a block rule on UFW.

    There are some wacky script workarounds but the real solution is to install & use a proper firewall like firewalld (firewall-cmd command) and not the joke utilities of Canonical/Ubuntu (ufw, netplan, etc).

    At which point you might as well chuck Ubuntu into the trash since you’d be replacing a bunch if its defaults anyway, and just stick with Debian or another quality stable distro like OpenSUSE.

    • notthebees@reddthat.com
      link
      fedilink
      arrow-up
      4
      ·
      5 days ago

      Wouldn’t docker do the same with firewalld?

      It acknowledges that it exists and just still uses it’s own rules. You’d still have to configure it, configuration is just less stupid than ufw with docker.

      My question is, who thought this was acceptable behavior at docker?

      • mlg@lemmy.world
        link
        fedilink
        English
        arrow-up
        1
        ·
        19 hours ago

        Sorta depends because firewalld has proper firewall zones, and docker uses its own zone name if firewalld is installed.

        Usually the default policy on distros that use firewalld will also apply the same base ruleset to the docker zone (or preconfigured zone rules for docker), in which case it should work out of box.

        If its Ubuntu, you might need to add a rule manually, but at least the rule will apply to docker traffic instead of getting completely bypassed like UFW.

        My question is, who thought this was acceptable behavior at docker?

        Exactly lol. I use podman and it does a much better job of integrating with the firewall with netavark.

        The fact that Docker hasn’t bothered to fix this or use common OCI standards is why I don’t reccomend using it at all over podman.

    • TootGuitar@sh.itjust.works
      link
      fedilink
      arrow-up
      5
      arrow-down
      1
      ·
      6 days ago

      I’ve been bitten by this before.

      OP, this guide reeks of inexperience. It’s admirable that you’re trying to help, but there are footguns in just about every section of the post.