{"id":840,"date":"2026-08-10T23:58:39","date_gmt":"2026-08-10T23:58:39","guid":{"rendered":"https:\/\/virtualserversvps.com\/blog\/?p=840"},"modified":"2026-08-10T23:58:39","modified_gmt":"2026-08-10T23:58:39","slug":"automated-security-updates-unattended-upgrades-vps","status":"publish","type":"post","link":"https:\/\/virtualserversvps.com\/blog\/automated-security-updates-unattended-upgrades-vps\/","title":{"rendered":"Automated Security Updates on a VPS: unattended-upgrades Setup"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Goal: keep a Debian or Ubuntu VPS patched against security vulnerabilities without logging in every week. This guide sets up <code>unattended-upgrades<\/code>, restricts it to security updates, adds reboot handling and email notifications, then covers the equivalent <code>dnf-automatic<\/code> setup for RHEL\/Fedora. Prerequisites: root access and a working outbound mail path or a webhook URL.<\/p>\n\n\n<h2 class=\"wp-block-heading\">Why automate patching at all<\/h2>\n\n\n<ul class=\"wp-block-list\"><li>The median time from CVE disclosure to public exploit is under 15 days; manual monthly patching is too slow<\/li><li>A compromised VPS is often used as a spam relay or cryptocurrency miner within hours<\/li><li>Automated security-only updates rarely break apps; full dist-upgrades are what you should review manually<\/li><\/ul>\n\n\n<p class=\"wp-block-paragraph\">Most providers publish their patch SLA, but even managed VPS plans do not patch the OS on unmanaged tiers. On a self-managed VPS, unattended-upgrades is the cheapest insurance you can install.<\/p>\n\n\n<h2 class=\"wp-block-heading\">Install and enable unattended-upgrades<\/h2>\n\n\n<p class=\"wp-block-paragraph\">On Debian\/Ubuntu:<\/p>\n\n\n<pre class=\"wp-block-code\"><code>sudo apt update\nsudo apt install -y unattended-upgrades apt-listchanges\nsudo dpkg-reconfigure -plow unattended-upgrades<\/code><\/pre>\n\n\n<p class=\"wp-block-paragraph\">Answer \u201cYes\u201d when asked whether to download and install stable updates. The package creates <code>\/etc\/apt\/apt.conf.d\/50unattended-upgrades<\/code>; verify it is active:<\/p>\n\n\n<pre class=\"wp-block-code\"><code>sudo unattended-upgrades --dry-run --debug<\/code><\/pre>\n\n\n<p class=\"wp-block-paragraph\">The dry run must show that security updates would be installed and end without errors. On Ubuntu, the <code>20auto-upgrades<\/code> file in <code>\/etc\/apt\/apt.conf.d\/<\/code> controls the automatic update and upgrade flags \u2014 both should be <code>\u201c1\u201d<\/code>.<\/p>\n\n\n<h2 class=\"wp-block-heading\">Restrict to security updates only<\/h2>\n\n\n<p class=\"wp-block-paragraph\">Open the main config and uncomment only the security origins; leave the rest commented out:<\/p>\n\n\n<pre class=\"wp-block-code\"><code>sudo nano \/etc\/apt\/apt.conf.d\/50unattended-upgrades\n\nUnattended-Upgrade::Allowed-Origins {\n    \"${distro_id}:${distro_codename}-security\";\n};<\/code><\/pre>\n\n\n<p class=\"wp-block-paragraph\">This prevents the machine from auto-installing new package versions from normal repos, which is where most upgrade-related breakage comes from. If you also run an LTS kernel, you can add the <code>-updates<\/code> origin, but start security-only.<\/p>\n\n\n<h2 class=\"wp-block-heading\">Pin what gets installed<\/h2>\n\n\n<p class=\"wp-block-paragraph\">Sometimes you want to block a specific package from ever being auto-upgraded \u2014 for example a patched kernel that conflicts with your vendor&#8217;s modules, or a database binary your application is pinned against. Blacklist it explicitly:<\/p>\n\n\n<pre class=\"wp-block-code\"><code>Unattended-Upgrade::Package-Blacklist {\n    \"linux-image-5.15.*\";\n    \"mysql-server\";\n};<\/code><\/pre>\n\n\n<p class=\"wp-block-paragraph\">The blacklist accepts regex patterns, so <code>linux-image-.*<\/code> disables all kernel auto-upgrades. Use this sparingly: every blacklisted security update is a vulnerability you are choosing to patch manually.<\/p>\n\n\n<h2 class=\"wp-block-heading\">What happens on failure<\/h2>\n\n\n<p class=\"wp-block-paragraph\">If a package fails to install, unattended-upgrades sends a mail (if configured) and leaves the package in a broken state \u2014 it does not retry aggressively. Check the log after any manual apt run, and watch for repeated failure lines:<\/p>\n\n\n<pre class=\"wp-block-code\"><code>grep -i error \/var\/log\/unattended-upgrades\/unattended-upgrades.log | tail<\/code><\/pre>\n\n\n<p class=\"wp-block-paragraph\">A common failure is a held package (<code>apt-mark hold<\/code>) that you forgot about, or a config file conflict from a previous manual edit. Fix the conflict and run <code>sudo unattended-upgrades<\/code> again to confirm the queue drains.<\/p>\n\n\n<h2 class=\"wp-block-heading\">Reboot handling and notifications<\/h2>\n\n\n<p class=\"wp-block-paragraph\">Kernel updates need a reboot to take effect. Configure automatic reboots at a quiet hour and send yourself an email:<\/p>\n\n\n<pre class=\"wp-block-code\"><code>Unattended-Upgrade::Automatic-Reboot \"true\";\nUnattended-Upgrade::Automatic-Reboot-Time \"03:30\";\nUnattended-Upgrade::Mail \"admin@example.com\";<\/code><\/pre>\n\n\n<p class=\"wp-block-paragraph\">If you prefer chat notifications, point the mail line at a service that forwards to Slack or Telegram, or watch <code>\/var\/log\/unattended-upgrades\/unattended-upgrades.log<\/code> with a log-shipping agent. Test the mail path with <code>mail<\/code> or a curl webhook before relying on it.<\/p>\n\n\n<h2 class=\"wp-block-heading\">RHEL\/Fedora: dnf-automatic<\/h2>\n\n\n<p class=\"wp-block-paragraph\">On AlmaLinux, Rocky, or Fedora the equivalent is:<\/p>\n\n\n<pre class=\"wp-block-code\"><code>sudo dnf install -y dnf-automatic\nsudo systemctl enable --now dnf-automatic.timer<\/code><\/pre>\n\n\n<p class=\"wp-block-paragraph\">Edit <code>\/etc\/dnf\/automatic.conf<\/code>: set <code>apply_updates = yes<\/code> and, under <code>[emitters]<\/code>, <code>emit_via = motd<\/code> plus your preferred email or command emitter. Check the timer with <code>systemctl list-timers dnf-automatic.timer<\/code>.<\/p>\n\n\n<h2 class=\"wp-block-heading\">Verify it actually runs<\/h2>\n\n\n<p class=\"wp-block-paragraph\">After configuring, confirm the service and timers are live:<\/p>\n\n\n<pre class=\"wp-block-code\"><code>systemctl status unattended-upgrades\ncat \/var\/log\/unattended-upgrades\/unattended-upgrades.log | tail -20<\/code><\/pre>\n\n\n<p class=\"wp-block-paragraph\">Force a run to confirm end-to-end behavior: <code>sudo unattended-upgrades<\/code>. You should see newly installed packages in the log and, if any were pending, a reboot at the configured time. Combine this with key-only SSH and a firewall \u2014 <a href=\"https:\/\/virtualserversvps.com\/\">virtualserversvps.com<\/a> has a full hardening checklist for the rest of the setup.<\/p>\n\n\n<p class=\"wp-block-paragraph\">Automated patching is one layer; snapshots are the second. Before a major change or at least weekly, take a provider snapshot so a bad update is a five-minute rollback instead of a rebuild. <a href=\"https:\/\/virtualserversvps.com\/#providers\">see the full specs and pricing on our VPS comparison page<\/a> to see which providers include free snapshots on entry plans.<\/p>\n\n\n<p class=\"wp-block-paragraph\">If you would rather not maintain patching yourself, <a href=\"https:\/\/cloudways.com\/en\/?id=2010927&amp;data1=virtualserversvps\" rel=\"noreferrer noopener sponsored\" target=\"_blank\">Cloudways managed VPS hosting<\/a> applies OS and stack patches on managed plans with a staging area for testing \u2014 at a higher price than unmanaged VPS, but with the operational work removed.<\/p>\n\n","protected":false},"excerpt":{"rendered":"<p>Goal: keep a Debian or Ubuntu VPS patched against security vulnerabilities without logging in every week. This guide sets up unattended-upgrades, restricts it to security updates, adds reboot handling and&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"iawp_total_views":0,"footnotes":""},"categories":[4],"tags":[],"class_list":["post-840","post","type-post","status-publish","format-standard","hentry","category-security-compliance"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v26.1 (Yoast SEO v26.1) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Automated Security Updates on a VPS: unattended-upgrades Setup - Virtual Servers VPS Blog<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/virtualserversvps.com\/blog\/automated-security-updates-unattended-upgrades-vps\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Automated Security Updates on a VPS: unattended-upgrades Setup\" \/>\n<meta property=\"og:description\" content=\"Automated Security Updates on a VPS: unattended-upgrades Setup\" \/>\n<meta property=\"og:url\" content=\"https:\/\/virtualserversvps.com\/blog\/automated-security-updates-unattended-upgrades-vps\/\" \/>\n<meta property=\"og:site_name\" content=\"Virtual Servers VPS Blog\" \/>\n<meta property=\"article:published_time\" content=\"2026-08-10T23:58:39+00:00\" \/>\n<meta name=\"author\" content=\"Virtual-Servers-Vps-Editor\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Virtual-Servers-Vps-Editor\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/virtualserversvps.com\/blog\/automated-security-updates-unattended-upgrades-vps\/\",\"url\":\"https:\/\/virtualserversvps.com\/blog\/automated-security-updates-unattended-upgrades-vps\/\",\"name\":\"Automated Security Updates on a VPS: unattended-upgrades Setup - Virtual Servers VPS Blog\",\"isPartOf\":{\"@id\":\"https:\/\/virtualserversvps.com\/blog\/#website\"},\"datePublished\":\"2026-08-10T23:58:39+00:00\",\"author\":{\"@id\":\"https:\/\/virtualserversvps.com\/blog\/#\/schema\/person\/82a299a8284a66ff49f97c74684724a0\"},\"breadcrumb\":{\"@id\":\"https:\/\/virtualserversvps.com\/blog\/automated-security-updates-unattended-upgrades-vps\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/virtualserversvps.com\/blog\/automated-security-updates-unattended-upgrades-vps\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/virtualserversvps.com\/blog\/automated-security-updates-unattended-upgrades-vps\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/virtualserversvps.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Automated Security Updates on a VPS: unattended-upgrades Setup\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/virtualserversvps.com\/blog\/#website\",\"url\":\"https:\/\/virtualserversvps.com\/blog\/\",\"name\":\"Virtual Servers VPS Blog\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/virtualserversvps.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/virtualserversvps.com\/blog\/#\/schema\/person\/82a299a8284a66ff49f97c74684724a0\",\"name\":\"Virtual-Servers-Vps-Editor\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/virtualserversvps.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/d820b15f1cd028e97610d9adf536df7be5cb6423869967037d468d5355fa003f?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/d820b15f1cd028e97610d9adf536df7be5cb6423869967037d468d5355fa003f?s=96&d=mm&r=g\",\"caption\":\"Virtual-Servers-Vps-Editor\"},\"sameAs\":[\"https:\/\/virtualserversvps.com\/blog\"],\"url\":\"https:\/\/virtualserversvps.com\/blog\/author\/virtualserversvps\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Automated Security Updates on a VPS: unattended-upgrades Setup - Virtual Servers VPS Blog","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/virtualserversvps.com\/blog\/automated-security-updates-unattended-upgrades-vps\/","og_locale":"en_US","og_type":"article","og_title":"Automated Security Updates on a VPS: unattended-upgrades Setup","og_description":"Automated Security Updates on a VPS: unattended-upgrades Setup","og_url":"https:\/\/virtualserversvps.com\/blog\/automated-security-updates-unattended-upgrades-vps\/","og_site_name":"Virtual Servers VPS Blog","article_published_time":"2026-08-10T23:58:39+00:00","author":"Virtual-Servers-Vps-Editor","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Virtual-Servers-Vps-Editor","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/virtualserversvps.com\/blog\/automated-security-updates-unattended-upgrades-vps\/","url":"https:\/\/virtualserversvps.com\/blog\/automated-security-updates-unattended-upgrades-vps\/","name":"Automated Security Updates on a VPS: unattended-upgrades Setup - Virtual Servers VPS Blog","isPartOf":{"@id":"https:\/\/virtualserversvps.com\/blog\/#website"},"datePublished":"2026-08-10T23:58:39+00:00","author":{"@id":"https:\/\/virtualserversvps.com\/blog\/#\/schema\/person\/82a299a8284a66ff49f97c74684724a0"},"breadcrumb":{"@id":"https:\/\/virtualserversvps.com\/blog\/automated-security-updates-unattended-upgrades-vps\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/virtualserversvps.com\/blog\/automated-security-updates-unattended-upgrades-vps\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/virtualserversvps.com\/blog\/automated-security-updates-unattended-upgrades-vps\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/virtualserversvps.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Automated Security Updates on a VPS: unattended-upgrades Setup"}]},{"@type":"WebSite","@id":"https:\/\/virtualserversvps.com\/blog\/#website","url":"https:\/\/virtualserversvps.com\/blog\/","name":"Virtual Servers VPS Blog","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/virtualserversvps.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/virtualserversvps.com\/blog\/#\/schema\/person\/82a299a8284a66ff49f97c74684724a0","name":"Virtual-Servers-Vps-Editor","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/virtualserversvps.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/d820b15f1cd028e97610d9adf536df7be5cb6423869967037d468d5355fa003f?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/d820b15f1cd028e97610d9adf536df7be5cb6423869967037d468d5355fa003f?s=96&d=mm&r=g","caption":"Virtual-Servers-Vps-Editor"},"sameAs":["https:\/\/virtualserversvps.com\/blog"],"url":"https:\/\/virtualserversvps.com\/blog\/author\/virtualserversvps\/"}]}},"_links":{"self":[{"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/posts\/840","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/comments?post=840"}],"version-history":[{"count":1,"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/posts\/840\/revisions"}],"predecessor-version":[{"id":841,"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/posts\/840\/revisions\/841"}],"wp:attachment":[{"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/media?parent=840"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/categories?post=840"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/tags?post=840"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}