HƯỚNG DẪN Gửi email tự động thông báo trên Debian/Ubuntu Linux

Thảo luận trong 'KIẾN THỨC VPS/SERVER' bắt đầu bởi quyet1990, 15/12/16.

  1. quyet1990

    quyet1990 New Member

    Tham gia ngày:
    22/10/16
    Bài viết:
    220
    Đã được thích:
    0
    Làm thế nào để buộc apt-get gửi cho tôi email khi nâng cấp hoặc cập nhật bảo mật có sẵn trong Debian hay Ubuntu Linux? Tôi có cần phải viết một script mà tạo ra một email với một danh sách của tất cả các gói hiện đang chờ nâng cấp?

    Không, bạn không phải viết một script. Bạn cần phải sử dụng lệnh apticron ( script để thông báo). apticron chủ yếu dành cho việc thông báo tự động cập nhật bảo mật chờ xử lý nhưng cũng có thể được sử dụng trong nhiều tình huống khác nơi mà việc cập nhật kịp thời là cần thiết.

    Cài đặt apticron
    Gõ lệnh sau tại cửa sổ dòng lệnh:
    Mã:
     apt-get update
    apt-get install apticron 
    Cấu hình apticron gửi thông báo email
    Tập tin cấu hình mặc định nằm ở /etc/apticron/apticron.conf. Mở tập tin sử dụng trình soạn thảo văn bản:
    Mã:
     vi /etc/apticron/apticron.conf 
    Bạn cần phải thiết lập địa chỉ email để gửi email thông báo như sau:
    Mã:
     EMAIL="vivek@aluhost.com" 
    Tập tin cấu hình mẫu của tôi:
    Mã:
    # apticron.conf
    #
    # set EMAIL to a list of addresses which will be notified of impending updates
    #
    EMAIL="vivek@aluhost.com "
    
    #
    # 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"
    
    
    Lưu lại và đóng tập tin. /etc/cron.daily/apticron là script cron để thực hiện apticron hằng ngày và nó sẽ gửi cho bạn notfication khi cập nhật có sẵn.

    Dưới đây là một email mẫu:
    Mã:
    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
    
    Bạn sẽ nhận được một email khi bản cập nhật bảo mật được phát hành bởi đội ngũ an ninh Debian/Ubuntu. Tôi cũng đề nghị đăng ký vào Debian email securityUbuntu Linux security để lấy thông tin cập nhật thông qua RSS hoặc email.
     

Chia sẻ trang này

Đang tải...