Prerequisites
Before setting up automatic updates, make sure you have:
- SSH access to your VPS with root or sudo privileges
- Your server IP address and password
💡 Automatic security updates ensure your server stays protected against known vulnerabilities without manual intervention.
Method 1: Ubuntu/Debian (unattended-upgrades)
Step 1: Connect to Your VPS
ssh hxroot@YOUR_SERVER_IP -p 22Step 2: Install unattended-upgrades
apt updateapt install unattended-upgrades -yStep 3: Configure Automatic Updates
dpkg-reconfigure --priority=low unattended-upgradesSelect Yes when prompted.
Step 4: Review Configuration (Optional)
nano /etc/apt/apt.conf.d/50unattended-upgradesKey settings to check:
Unattended-Upgrade::Allowed-Origins {
"${distro_id}:${distro_codename}-security";
// "${distro_id}:${distro_codename}-updates";
// "${distro_id}:${distro_codename}-proposed";
// "${distro_id}:${distro_codename}-backports";
};Uncomment the security line (it should be active by default).
Step 5: Enable Automatic Reboot (Optional)
If you want the server to reboot automatically when needed:
nano /etc/apt/apt.conf.d/50unattended-upgradesUncomment and set:
Unattended-Upgrade::Automatic-Reboot "true";
Unattended-Upgrade::Automatic-Reboot-Time "03:00";Step 6: Check Status
systemctl status unattended-upgradesStep 7: Test Configuration
unattended-upgrades --dry-runMethod 2: CentOS/Rocky/AlmaLinux (dnf-automatic)
Step 1: Install dnf-automatic
dnf install dnf-automatic -yStep 2: Configure Automatic Updates
nano /etc/dnf/automatic.confSet these values:
[commands]
upgrade_type = security
random_sleep = 0
[email]
email_from = root@example.com
email_to = admin@example.com
email_host = localhost
[install]
apply_updates = yes
[system_reboot]
reboot = yes
reboot_messages = yesStep 3: Enable and Start Service
systemctl enable --now dnf-automatic.timerStep 4: Check Timer Status
systemctl list-timers | grep dnf-automaticMethod 3: Configure Email Alerts (Ubuntu/Debian)
To receive email when updates are installed:
apt install mailutils -yEdit unattended-upgrades config:
nano /etc/apt/apt.conf.d/50unattended-upgradesAdd or uncomment:
Unattended-Upgrade::Mail "admin@example.com";
Unattended-Upgrade::MailReport "only-on-error";View Automatic Update Logs
cat /var/log/unattended-upgrades/unattended-upgrades.logcat /var/log/unattended-upgrades/unattended-upgrades-dpkg.logManually Run Unattended-Upgrades
unattended-upgrades -vDisable Automatic Updates
If you prefer manual control:
systemctl stop unattended-upgradessystemctl disable unattended-upgradesOr remove the package:
apt remove unattended-upgrades -yCheck What Updates Are Available
apt list --upgradableBest Practices
- Keep security updates enabled
- Test major version updates on staging server first
- Review logs weekly to ensure updates are applying
- Set up monitoring to alert if auto-updates fail
- For production servers, consider rebooting during low-traffic hours
✅ Automatic security updates have been configured. Your Hostxpeed VPS will now install security patches automatically.