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
    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.

  • talkingpumpkin@lemmy.world
    link
    fedilink
    arrow-up
    1
    ·
    8 days ago

    I really appreciate the effort but… how to say it?.. it might be useful to make sure you understand a topic before trying to teach it to others :)

    Some notes:

    Create a Non-Root Administrative User

    Not as important as most people think (local privilege escalation is a thing, and it’s also quite easy for your user to alias sudo to something that will capture your password the next time you type it).

    Basically: if an hostile actor gets a shell on your server, you are fucked anyway.

    sudo usermod -aG docker your_username

    This is the same as being root. Yep, the very same thing you went that whole length to avoid :)

    Automate Maintenance with a System Update Script

    Look into unattended upgrades. Also… it’s not automation if you have to run a script manually :)