惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Attack and Defense Labs
Attack and Defense Labs
T
Threatpost
C
Cybersecurity and Infrastructure Security Agency CISA
H
Hackread – Cybersecurity News, Data Breaches, AI and More
I
Intezer
C
Cyber Attacks, Cyber Crime and Cyber Security
The Register - Security
The Register - Security
量子位
Security Latest
Security Latest
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
大猫的无限游戏
大猫的无限游戏
小众软件
小众软件
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
C
CXSECURITY Database RSS Feed - CXSecurity.com
MyScale Blog
MyScale Blog
J
Java Code Geeks
Apple Machine Learning Research
Apple Machine Learning Research
Google DeepMind News
Google DeepMind News
WordPress大学
WordPress大学
Spread Privacy
Spread Privacy
Jina AI
Jina AI
博客园 - 【当耐特】
P
Palo Alto Networks Blog
Last Week in AI
Last Week in AI
SecWiki News
SecWiki News
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
G
GRAHAM CLULEY
宝玉的分享
宝玉的分享
Hacker News - Newest:
Hacker News - Newest: "LLM"
T
The Blog of Author Tim Ferriss
V
Vulnerabilities – Threatpost
有赞技术团队
有赞技术团队
T
Tor Project blog
H
Hacker News: Front Page
A
Arctic Wolf
NISL@THU
NISL@THU
A
About on SuperTechFans
云风的 BLOG
云风的 BLOG
Engineering at Meta
Engineering at Meta
V
V2EX
N
News and Events Feed by Topic
Webroot Blog
Webroot Blog
Know Your Adversary
Know Your Adversary
P
Privacy International News Feed
I
InfoQ
D
Docker
L
LINUX DO - 最新话题
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
U
Unit 42

server – Ed_'s Blog

Crontab 使用笔记 – yywr's Blog 终于修了个梯子 – yywr's Blog 防火墙配置工具 UFW – yywr's Blog 说说 LNMP 面板 – yywr's Blog Linux 程序开机启动并保活:Systemd 进程守护管理工具 – yywr's Blog Linux 下自动挂载 Samba /CIFS 共享文件夹 – yywr's Blog Ubuntu 开机自动挂载第二块硬盘 – yywr's Blog 重装了家里的服务器系统 – yywr's Blog 构建网络私有书架,实现听书看书 – yywr's Blog 主机安装 Tiny Tiny RSS 踩坑记 – yywr's Blog
给 Debian 开了自动安全更新 – yywr's Blog
yywr · 2026-06-15 · via server – Ed_'s Blog

Skip to content

由于AI的关系,最近各种漏洞满天飞,但又无能为力,唯一能做就是利用 AI 做些以前做起来非常费劲的安全措施了

在 Debian/Ubuntu 系统中,使用 unattended-upgrades 工具可以实现仅自动安装安全更新,这是官方推荐的标准方案(来自AI整理)

  • 自动安装安全更新
  • 普通功能更新仍然手动
  • 自动清理旧包
  • 避免自动重启导致业务中断 也没什么重要业务,就重启吧

Debian 自动更新其实由两部分组成:

组件作用
apt-daily.timer自动刷新软件源缓存
apt-daily-upgrade.timer自动安装更新
unattended-upgrades真正执行自动升级(核心包)
/etc/apt/apt.conf.d/配置目录

第一步:安装与启用

大多数系统可能已安装,你可以通过以下命令确保安装并开启:

# 1. 安装工具
sudo apt update && sudo apt install unattended-upgrades -y

# 2. 启用自动更新(交互界面选 Yes)
sudo dpkg-reconfigure --priority=low unattended-upgrades

第二步:配置更新源(核心)

编辑配置文件,确保系统只从安全仓库拉取补丁

sudo nano /etc/apt/apt.conf.d/50unattended-upgrades

找到 Unattended-Upgrade::Allowed-Origins 部分,只保留 -security 这一行,其余带 -updates 的行请保持注释状态(行首有 //):

Unattended-Upgrade::Allowed-Origins {
    "${distro_id}:${distro_codename}-security";
    // "${distro_id}:${distro_codename}-updates";   // 必须注释,避免安装功能更新
    // "${distro_id}:${distro_codename}-backports";
};

补充说明:Debian 系统有时会使用不同的匹配模式,如 origin=Debian,codename=${distro_codename},label=Debian-Security,原理相同,只启用 Security 相关条目即可。

不要开启:”${distro_id}:${distro_codename}”; 否则会自动安装普通更新。

第三步:设置执行频率

编辑自动升级任务文件:

sudo nano /etc/apt/apt.conf.d/20auto-upgrades

确保或修改内容如下(1 代表每天执行):

APT::Periodic::Update-Package-Lists "1"; #每天更新软件列表
APT::Periodic::Download-Upgradeable-Packages "1";
APT::Periodic::Unattended-Upgrade "1"; #每天自动升级
APT::Periodic::AutocleanInterval "7";

第四步:可选的高级配置

如果希望内核更新后自动重启(慎重开启),可在 50unattended-upgrades 文件末尾添加:

Unattended-Upgrade::Automatic-Reboot "true"; #自动重启
Unattended-Upgrade::Automatic-Reboot-Time "02:00"; #重启时间
Unattended-Upgrade::Remove-Unused-Dependencies "true"; #自动清理旧包
Unattended-Upgrade::Remove-Unused-Kernel-Packages "true"; #自动清理旧 kernel
Unattended-Upgrade::SyslogEnable "true"; #开启日志,位置/var/log/unattended-upgrades/;unattended-upgrades.log;unattended-upgrades-dpkg.log

第五步:验证配置

运行试运行命令,检查系统是否会获取安全更新:

sudo unattended-upgrade --dry-run -d

查看日志可确认运行状态:

sudo cat /var/log/unattended-upgrades/unattended-upgrades.log

确认自动任务存在:

systemctl list-timers --all 'apt-daily*'
#应该看到:
# * apt-daily.timer
# * apt-daily-upgrade.timer