The Linux server security is indeed an essential task for sysadmins. One of the most fundamental ways to keep the Ubuntu server secure is by installing security updates on time to patch vulnerabilities. By default, the unattended-upgrades package installed, but you still need to configure a few options. It will automatically install software updates, including security updates. This page shows how to configure security updates automatically when released by the Ubuntu security team using an unattended-upgrades package.
Automatic unattended updates for Ubuntu 20.04 LTS
- Update the Ubuntu 20.04 LTS server for security patches, run:
sudo apt update && sudo apt upgrade
- Install unattended upgrades on Ubuntu if not installed. Type the following apt command
sudo apt install unattended-upgrades apt-listchanges bsd-mailx
- Turn on unattended security updates, run:
sudo dpkg-reconfigure -plow unattended-upgrades
- Configure automatic unattended updates, enter:
sudo vi /etc/apt/apt.conf.d/50unattended-upgrades
Set up alert email ID:
Unattended-Upgrade::Mail "[email protected]";
Automatically reboot Ubuntu box WITHOUT CONFIRMATION for kernel updates:
Unattended-Upgrade::Automatic-Reboot "true";
Finally edit the /etc/apt/listchanges.conf and set email ID:
[email protected]
Save and close the file.
Verify that it is working by running the following command:
sudo unattended-upgrades --dry-run