Bluehost Self-Managed VPS: How to Set Up Automatic Security Updates
Automatic security updates keep your server protected against the latest vulnerabilities without manual intervention. This is a critical best practice for any public-facing Self-Managed VPS.
This article discusses the following:
Prerequisites & Testing Connectivity
- You must have root or sudo privileges.
- Your server must be able to connect to official repositories (internet access).
- Ensure initial manual updates are done first, and that you have recent backups.
How to Test Repository Connectivity & Internet Access
Run one or more commands below to confirm internet and repo connectivity:
| Test | Command | What to Expect If OK |
|---|---|---|
| Ping public IP |
|
Shows replies:
|
| Ping domain |
|
Shows replies:
|
| Test DNF/YUM repo (AlmaLinux, Rocky, CentOS, Fedora) |
|
Shows repo/metadata fetch lines, e.g.:
|
| Test APT repo (Ubuntu, Debian) |
|
Shows download lines, e.g.:
|
- If you see “Could not resolve host” or “Failed to download”, your server does not have internet access or your DNS/repos are misconfigured.
- Successful responses mean your server can reach official repositories and is ready for automatic updates.
AlmaLinux, Rocky Linux, CentOS Stream, Fedora (dnf-automatic)
These systems use dnf-automatic for scheduled updates.
1. Install dnf-automatic:
sudo dnf install dnf-automatic -y
Example output:
Installed:
dnf-automatic-4.14.0-1.el9.noarch
Complete!
2. Enable and start the timer:
sudo systemctl enable --now dnf-automatic.timer
Example output:
Created symlink /etc/systemd/system/timers.target.wants/dnf-automatic.timer → /usr/lib/systemd/system/dnf-automatic.timer.
3. Edit the config file to set actions (default: download and apply security-only updates):
sudo nano /etc/dnf/automatic.conf
Look for these lines and set for security-only and automatic apply:
apply_updates = yes
upgrade_type = security
4. Check the timer status:
systemctl status dnf-automatic.timer
● dnf-automatic.timer - dnf-automatic timer
Loaded: loaded (/usr/lib/systemd/system/dnf-automatic.timer; enabled)
Active: active (waiting) since Wed 2024-07-10 08:00:00 UTC; 2h 10min ago
Ubuntu, Debian (unattended-upgrades)
Use unattended-upgrades for automatic security updates on Ubuntu and Debian.
1. Install unattended-upgrades:
sudo apt update
sudo apt install unattended-upgrades -y
Example output:
Setting up unattended-upgrades (2.8.1ubuntu1) ...
2. Enable automatic security updates:
sudo dpkg-reconfigure --priority=low unattended-upgrades
Example output:
Configuring unattended-upgrades
Automatically download and install stable updates? [Yes]
3. (Optional) Fine-tune /etc/apt/apt.conf.d/50unattended-upgrades:
Open the file and ensure security updates are enabled and adjust email/auto-reboot if desired.
4. Simulate a run to check readiness:
sudo unattended-upgrades --dry-run --debug
Example output includes lines similar to:
Checking: openssl
Packages that will be upgraded: openssl
When Do Automatic Security Updates Run?
- AlmaLinux, Rocky Linux, CentOS Stream, Fedora:
Security updates run automatically once daily viadnf-automatic.timer— by default at 6:00 am system time.
To check or adjust the schedule, run:
Sample output:systemctl list-timers dnf-automatic.timer
Advanced users: To customize the timer schedule, editNEXT LEFT LAST PASSED UNIT Wed 2024-07-10 06:00:00 UTC 7h left Wed 2024-07-09 06:00:04 UTC 16h ago dnf-automatic.timer/usr/lib/systemd/system/dnf-automatic.timer(then runsudo systemctl daemon-reload). - Ubuntu, Debian:
Security updates are applied daily, typically overnight (about 6:25am system time) through acron.dailyjob.
To check the last run or troubleshoot:
Or review the schedule inls -l /var/log/unattended-upgrades//etc/cron.daily/and/etc/apt/apt.conf.d/10periodic.
Notification Setup (Optional)
Would you like to receive an email every time an automatic update is installed or if there is a problem? Here’s how you can set up email alerts for your server’s security updates:
| OS/Stack | Notification Method | Setup Steps |
|---|---|---|
| AlmaLinux, Rocky Linux, CentOS Stream, Fedora | Email via dnf-automatic |
|
| Ubuntu, Debian | Email via unattended-upgrades |
|
- They do not provide a free relay service for you—you are just running your own system’s mail server to send system alert emails.
- For reliable mail delivery to Gmail or external addresses, you may need to set up additional mail relay settings or use a service (to avoid spam filters).
- For VPS alerts and security email, the free local MTA setup is usually enough.
Tip: For reliable email delivery to Gmail or other external mailboxes, consider using SMTP relay settings or an external email service to avoid spam issues.
You will receive alerts when security updates are installed (or when there are errors, depending on configuration).
Advanced: Scheduling & OS-Specific Tips
Want more control over when updates happen, or need to troubleshoot OS-specific issues? Here are some advanced tips:
AlmaLinux, Rocky Linux, CentOS Stream, Fedora (dnf-automatic)
- Change update frequency/time:
Edit the timer file:
Modify (or add) thesudo nano /usr/lib/systemd/system/dnf-automatic.timerOnCalendarline in the[Timer]section, e.g.:
(runs daily at 3:00 am)OnCalendar=*-*-* 03:00:00
Other options:OnCalendar=Mon *-*-* 03:00:00(weekly Monday at 3 am)OnCalendar=hourly(every hour)OnCalendar=*-*-* 03,15:00:00(twice daily at 3am/3pm)
More info: See systemd.time documentation.sudo systemctl daemon-reload sudo systemctl restart dnf-automatic.timer - Disable/enable automatic updates:
sudo systemctl stop dnf-automatic.timer # Disable sudo systemctl start dnf-automatic.timer # Enable/Restart
Ubuntu, Debian (unattended-upgrades)
- Change update frequency:
Edit this file:
Example for daily checks/updates:sudo nano /etc/apt/apt.conf.d/10periodic
(Set to "7" for weekly, "0" to disable, "2" for every other day, etc.)APT::Periodic::Update-Package-Lists "1"; APT::Periodic::Unattended-Upgrade "1"; - Advanced scheduling:
Cron jobs generally run around 6:25am system time, but you can move the main script to/etc/cron.hourly/or use a custom cron job if you want advanced control. - Disable/enable automatic updates:
sudo dpkg-reconfigure unattended-upgrades
How to verify your schedule:
- dnf-automatic:
systemctl list-timers - unattended-upgrades: View logs:
ls -l /var/log/unattended-upgrades/
If you adjust the schedule, always monitor your logs and check mail alerts to ensure updates are running as expected.
Testing & Monitoring Automatic Updates
- Check update logs:
RHEL/Alma/Rocky/CentOS:
Ubuntu/Debian:sudo journalctl -u dnf-automatic.servicecat /var/log/unattended-upgrades/unattended-upgrades.log - Set up email notifications in the config file to alert you to each update event.
Summary
Enabling automatic security updates is one of the easiest and most effective ways to harden your Self-Managed VPS, reduce downtime, and protect your data. Test to confirm they work, review your logs, and remember to keep regular backups!
Related Articles
- Bluehost Self-Managed VPS: OS Comparison
- Using CentOS with Bluehost Self-Managed VPS
- Using ALMALinux with Bluehost Self-Managed VPS
- Using Rocky Linux with Bluehost Self-Managed VPS
- Using Ubuntu with Bluehost Self-Managed VPS
- Using Fedora with Bluehost Self-Managed VPS
- Using Debian with Bluehost Self-Managed VPS
- Guide to Purchasing Self-Managed VPS Hosting with Bluehost