在 Debian Stretch 上设置自动升级

栏目: 服务器 · 发布时间: 7年前

内容简介:不少博主,出于安全、稳定的考虑,在自己的服务器上使用了 Debian 操作系统。我们知道,对于多数应用环境,特别是 LNMP 环境,绝大多数安全更新可以自行安装,本文我们将详细介绍,如何在 Debian 环境下自行下载安装最新的系统安全补丁。命令如下;安装完成后,编辑未完成的升级配置:

不少博主,出于安全、稳定的考虑,在自己的服务器上使用了 Debian 操作系统。我们知道,对于多数应用环境,特别是 LNMP 环境,绝大多数安全更新可以自行安装,本文我们将详细介绍,如何在 Debian 环境下自行下载安装最新的系统安全补丁。 在 Debian Stretch 上设置自动升级

首选,我们安装关联的系统包

命令如下;

apt -y install unattended-upgrades apt-listchanges apticron

安装完成后,编辑未完成的升级配置:

vi /etc/apt/apt.conf.d/50unattended-upgrades

将下面的内容粘贴到这个文件中,然后用它修改条目,记得移除那些小行星。

APT::Periodic::Update-Package-Lists "1";
APT::Periodic::Download-Upgradeable-Packages "1";
APT::Periodic::AutocleanInterval "7";
APT::Periodic::Unattended-Upgrade "1";
Unattended-Upgrade::Mail "my_email@debian.cn";

// Automatically upgrade packages from these
Unattended-Upgrade::Origins-Pattern {
    "o=Debian,a=stable";
    "o=Debian,a=stable-updates";
    "o=Debian,a=proposed-updates";
    "origin=Debian,codename=${distro_codename},label=Debian-Security";
};

// You can specify your own packages to NOT automatically upgrade here
Unattended-Upgrade::Package-Blacklist {
//    "vim";
//    "libc6";
//    "libc6-dev";
//    "libc6-i686";
};

Unattended-Upgrade::MailOnlyOnError "true";
Unattended-Upgrade::Automatic-Reboot "false";

注意:如果您希望服务器在必要时重新启动,您可以将自动重新引导设置为true。

使用 “apticron” 来管理 APT 更新的自动执行

Apticron 我们已经在第一步安装,在此略过。更新 apticron.conf 的配置文件。打开 /etc/apticron/apticron.conf将电子邮件变量设置为您的电子邮件地址,这样您就可以收到更改列表。

EMAIL="My_user_name@debian.cn"
DIFF_ONLY="1"
LISTCHANGES_PROFILE="apticron"
SYSTEM="www.debian.cn"
NOTIFY_HOLDS="0"
NOTIFY_NO_UPDATES="0"

打开 /etc/apt/listchanges.conf 以便配置APT来保存对数据库的更改:

[apt]
frontend=pager
email_address=My_user_name@debian.cn*
confirm=0
save_seen=/var/lib/apt/listchanges.db
which=news

您可以使用调试模式手动运行unattended-upgrade,看看它是否正常工作:

# unattended-upgrade -d
Initial blacklisted packages:
Initial whitelisted packages:
Starting unattended upgrades script
Allowed origins are: ['o=Debian,a=stable', 'o=Debian,a=stable-updates', 'o=Debian,a=proposed-updates', 'origin=Debian,codename=stretch,label=Debian-Security']
Checking: base-files ([])
Checking: ca-certificates ([, ])
...
All upgrades installed
InstCount=0 DelCount=0 BrokenCount=0
Extracting content from '/var/log/unattended-upgrades/unattended-upgrades-dpkg.log' since '2018-09-10 11:42:56'

以上所述就是小编给大家介绍的《在 Debian Stretch 上设置自动升级》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

The Everything Store

The Everything Store

Brad Stone / Little, Brown and Company / 2013-10-22 / USD 28.00

The definitive story of Amazon.com, one of the most successful companies in the world, and of its driven, brilliant founder, Jeff Bezos. Amazon.com started off delivering books through the mail. Bu......一起来看看 《The Everything Store》 这本书的介绍吧!

RGB转16进制工具
RGB转16进制工具

RGB HEX 互转工具

XML 在线格式化
XML 在线格式化

在线 XML 格式化压缩工具

html转js在线工具
html转js在线工具

html转js在线工具