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!

  • UnknownUniverse@lemmy.mlOP
    link
    fedilink
    arrow-up
    6
    ·
    2 days ago

    Editor’s Note & Update

    Following some comments on this guide, a couple of key clarifications are worth adding:

    Docker Permissions & Rootless Containers: A few eagle-eyed readers rightly pointed out that adding your user to the  docker  group is functionally equivalent to giving yourself root-level access to the host machine (since container runtimes run with root privileges).

    I have updated to remove that shortcut. While container security can go much deeper (such as setting up rootless Docker or Podman), this guide focuses on keeping things simple as a solid quick-start baseline for security.

    System Updates, while fully automated background upgrades have their place, many admins including myself prefer a hands-on approach. Running a script manually and using  needrestart  gives you deliberate control over when services are recycled and ensures you aren’t caught off guard by unexpected reboots.

    Thanks you all for reading and I always welcome any feedback on my work.

    • MangoCat@lemmy.sdf.org
      link
      fedilink
      arrow-up
      3
      ·
      16 hours ago

      I’m going to take exception right here:

      “Install Essential Administrative Tools”

      The first thing you do to lock down a server is: Uninstall everything that is non-essential.

      Do you need any wireless access to the server? If not, remove all WiFi, Bluetooth, and other wireless support from the kernel (block the modules).

      Do you need anyone to be able to plug in a USB dongle that can bridge to ethernet? Or anything else?

      Remove support for everything you don’t need first, un-necessary attack surface is the first foot-gun.

      Are these administrative tools all essential? Keep / install what you need, sudo apt purge the rest.

      Do you know WTF you’re doing with Docker containers and firewalls / iptables? The thing to do is learn how that really works, before getting your application servers / containers up on the open internet.

      Do you know what un-necessary attack surfaces exist within your container images? That’s another step toward a hardened system - know what you’re running, know what that means, and

      above all else: run as little as possible.