On Debian/Ubuntu servers I enable unattended-upgrades for the security pocket only, with automatic reboot disabled and a notification instead. Feature updates and major versions stay manual. The common failure is not the tool, it is forgetting that a kernel or libc update does nothing until the service or the machine restarts: needrestart (or checkrestart) tells you what still runs old code.

Also worth checking: apt-get -s upgrade weekly, so you see what is waiting.

What is your policy: fully automatic with reboots in a maintenance window, notify-only, or everything by hand? Any horror story with auto-updates?

Open-source agent that lists the versions exposed by a Linux host: https://github.com/AttackScout/attackscout-agent — I work on AttackScout.

  • Dingaling
    link
    fedilink
    English
    7•
    edit-2
    4 hours ago

    People seem to love overcomplicating this subject but it’s not hard

    APT based distros:

    apt-get update
    apt-get upgrade -y
    reboot
    

    EL distros:

    dnf update
    reboot
    
    • Use root crontab to schedule, or one of the /etc/cron.[daily|weekly|monthly] dirs. I use a variety of schedules at work - 2nd and 4th Tuesdays of each month. Every day for DMZs. 70 or 80 vms at a time.

    Provisos:

    • Ensure root email reaches you, so you see any repo or package manager errors from crontab.
    • You can wrap this in a bash script. Or use ansible. Add whatever additions you need (notifications, logger lines, shutting stuff down in a particular order - whatever your pets need).

    Defences:

    • You should have reliable repos already. Remember that dnf can have multiple sources per repo if you want redundancy (We use an internal mirror for speed, but if that does go down, then the vms failover to the internet)
    • What about a bad package? It happens, but rare. At scale, ansible with batches and break lines if a certain percentage fail. Use inventory groups to prioritise non-production machines first as canaries)
    • Don’t trust a repo source against supply-chain attacks? Then never use their software, let alone add its repo. But you will have to trust your distro. No way around that.
    • Critical systems? Then you’re into the realm of soak-testing and staging. Beyond the scope of this, but even there, the actual patching is very similar, just with staged repos instead of live ones. And anyway, critical stuff should be HA.

    Benefits:

    • Rebooting often means finding problems faster. Your systems should always be able to reboot by themselves. Any failures need to be resolved or automated through. Anyone who is proud of their high uptimes needs taking outside and leaving by the bins.
    • Whilst you can check for needsrestart, what’s the point when you can reboot in less than a minute and be certain? Clear those caches and flush those buffers, recover leaking memory and freshen the place up, be 100% certain you’re using the latest kernel and every app has the latest library.

    We’ve been doing this for years on hundreds of vms, using Centos Linux, Rocky and Debian distros. Problems caused by reboots are negligible and would have been a problem anyway. Problems caused by bad distro packages are rare - maybe once a year. (I don’t recall any on Debian, but have had the odd one on Rocky and CentOs before it)

    Build bouncy systems. Don’t be scared of rebooting.