zoukankan      html  css  js  c++  java
  • 通过yum-cron对linux进行安全更新

    配置yum-cron工具。

    安装

    [root@localhost ~]# yum -y install yum-cron

    配置

    yum-cron有两个配置文件:/etc/yum/yum-cron.conf 和 /etc/yum/yum-cron-hourly.conf。这两个配置文件内容差不多,用于配置每天需要执行的内容和每小时需要执行的内容。

    在配置文件中,提供的更新策略为:

    [root@localhost ~]# vi /etc/yum/yum-cron.conf 
    [commands]
    #  What kind of update to use:
    # default                            = yum upgrade
    # security                           = yum --security upgrade
    # security-severity:Critical         = yum --sec-severity=Critical upgrade
    # minimal                            = yum --bugfix update-minimal
    # minimal-security                   = yum --security update-minimal
    # minimal-security-severity:Critical =  --sec-severity=Critical update-minimal
    default 默认的更新,类似yum update
    security 安全更新, 类似yum --secruity upgrade
    security-severity:Critical 重要的安全更新,类似yum --sec-severity=Critical upgrade
    minimal 最小化更新,类似yum --bugfix update-minimal
    minimal-security 最小化安全更新,类似yum --security update-minimal
    minimal-security-severity:Critical 最小化重要安全更新,类似yum --sec-severity=Critical update-minimal

    通过update-cmd指定相应的更新策略。
    如: 需要配置只需要更新重要的安全更新,则配置为

    update_cmd = security-severity:Critical

    apply_updates设置是否提交相应的安全更新,如果设置为no,则只会检测存在更新,但不会直接更新,如要自动更新,需将apply_updates设置为yes

    apply_updates = yes

    random_sleep设置最大的随机启动时间,设置随机启动是为了解决大量服务器同时启动更新,对服务器环境造成影响。(考虑的很周到呢,不同于我们通过crontab设置一个固定的时间进行更新)
    random_sleep的时间单位为秒。
    系统默认设置为6*60 = 360,即6小时:

    random_sleep = 360

    在生产环境,我们通常不愿意去更新系统的内核,那么,通过exclude和YUM_PARAMETER可以将内核类的更新排除掉.
    在CentOS/RHEL 7.x系统中,加入下面内容排除:

    exclude=kernel*

    在RHEL/CentOS 6.x系统中,加入以下内容排除:

    YUM_PARAMETER=kernel*

    配置参考:

    [root@ttt yum]# cat yum-cron.conf | grep -vE '^#|^$'
    [commands]
    update_cmd = security-severity:Critical
    update_messages = yes
    download_updates = yes
    apply_updates = yes
    random_sleep = 360
    exclude=kernel*
    [emitters]
    system_name = None
    emit_via = stdio
    output_width = 80
    [email]
    email_from = root@localhost
    email_to = root
    email_host = localhost
    [groups]
    group_list = None
    group_package_types = mandatory, default
    [base]
    debuglevel = -2
    mdpolicy = group:main

    配置完成后,需要配置 /etc/yum/yum-cron-hourly.conf 让yum-cron每小时都执行。如果需要让yum-cron每天执行一次,需要配置/etc/cron.daily/0yum-daily.cron。

    [root@ttt yum]# cat /etc/cron.hourly/0yum-hourly.cron 
    #!/bin/bash
    
    # Only run if this flag is set. The flag is created by the yum-cron init
    # script when the service is started -- this allows one to use chkconfig and
    # the standard "service stop|start" commands to enable or disable yum-cron.
    if [[ ! -f /var/lock/subsys/yum-cron ]]; then
      exit 0
    fi
    
    # Action!
    exec /usr/sbin/yum-cron /etc/yum/yum-cron-hourly.conf
    [root@ttt yum]# cat /etc/cron.daily/0yum-daily.cron
    #!/bin/bash
     
    # Only run if this flag is set. The flag is created by the yum-cron init
    # script when the service is started -- this allows one to use chkconfig and
    # the standard "service stop|start" commands to enable or disable yum-cron.
    if [[ ! -f /var/lock/subsys/yum-cron ]]; then
      exit 0
    fi
     
    # Action!
    exec /usr/sbin/yum-cron

    以上就是yum-cron的大概的配置信息。如果需要查看更详细的,可以通过系统的man命令。
    [root@ttt yum]# man yum-cron

  • 相关阅读:
    用栈实现队列
    “非常规”的漏洞挖掘思路与技巧-请求参数加密,js接口- 漏洞定级评分的标准与关注点-违规测试标准详解
    【linux 文件管理】2-文件目录命令
    EHC
    kali linux高级渗透测试第七课
    maltego CE社区版-Domain与DNS name
    name servers-域名服务器
    【linux 文件管理】1-文件目录结构
    web应用安全自学指南
    kali linux高级渗透测试第六课
  • 原文地址:https://www.cnblogs.com/liujunjun/p/12098992.html
Copyright © 2011-2022 走看看