Debian/Ubuntu Linux:在安全升级可用时发送自动电子邮件通知
时间:2020-01-09 10:37:14 来源:igfitidea点击:
在Debian或Ubuntu Linux上可用的升级或安全更新时,如何强制apt-get向我发送电子邮件?
我是否需要编写一个shell脚本来生成一封邮件,其中包含当前所有等待升级的软件包的列表?
不,您不必编写Shell脚本。
您需要使用apticron命令/脚本进行通知。
apticron主要用于自动通知未决的安全更新,但也可以用于许多其他需要及时更新的情况。
安装Apticron
在shell提示符下键入以下命令:
# apt-get update # apt-get install apticron
配置apticron发送电子邮件通知
默认的配置文件位于/etc/apticron/apticron.conf。
使用文本编辑器打开文件:
# vi /etc/apticron/apticron.conf
您需要设置电子邮件地址,以通过电子邮件发送通知,如下所示:
EMAIL="[email protected]"
我的示例配置文件:
# apticron.conf # # set EMAIL to a list of addresses which will be notified of impending updates # EMAIL="[email protected]" # # Set LISTCHANGES_PROFILE if you would like apticron to invoke apt-listchanges # with the --profile option. You should add a corresponding profile to # /etc/apt/listchanges.conf # # LISTCHANGES_PROFILE="apticron" # # Set SYSTEM if you would like apticron to use something other than the output # of "hostname -f" for the system name in the mails it generates # # SYSTEM="foobar.example.com" # # Set IPADDRESSNUM if you would like to configure the maximal number of IP # addresses apticron displays. The default is to display 1 address of each # family type (inet, inet6), if available. # # IPADDRESSNUM="1" # # Set IPADDRESSES to a whitespace seperated list of reachable addresses for # this system. By default, apticron will try to work these out using the # "ip" command # # IPADDRESSES="192.0.2.1 2001:db8:1:2:3::1"
保存并关闭文件。
/etc/cron.daily/apticron是每天执行apticron的cron脚本,当有可用更新时,它将发送通知。
Apticron电子邮件示例
这是电子邮件示例:
apticron report [Sun, 06 Jul 2008 07:07:23 +0000] ======================================================================== apticron has detected that some packages need upgrading on: vip.clicklinux.org [ 72.51.34.244 ::72.51.34.244 ] The following packages are currently pending an upgrade: libpcre3 6.7+7.4-4 ======================================================================== Package Details: Reading changelogs... --- Changes for pcre3 (libpcre3) -- pcre3 (6.7+7.4-4) stable-security; urgency=high * Non-maintainer upload by the security team. * Apply patch from Tavis Ormandy to fix a heap overflow in the compiler, triggered by patterns which contain options and multiple branches (CVE-2008-2371). -- Florian Weimer Fri, 04 Jul 2008 21:15:19 +0200 ======================================================================== You can perform the upgrade by issuing the command: aptitude dist-upgrade as root on vip.clicklinux.org It is recommended that you simulate the upgrade first to confirm that the actions that would be taken are reasonable. The upgrade may be simulated by issuing the command: aptitude -s -y dist-upgrade -- apticron
当Debian/Ubuntu安全团队发布安全更新时,您会收到一封电子邮件。
我还建议通过RSS或电子邮件订阅Debian电子邮件安全更新通知和Ubuntu Linux安全通知。