全部产品
Search
文档中心

:历史Linux镜像的问题的修复方案

更新时间:Mar 02, 2022

免责声明: 本文档可能包含第三方产品信息,该信息仅供参考。阿里云对第三方产品的性能、可靠性以及操作可能带来的潜在影响,不做任何暗示或其他形式的承诺。

问题描述

历史Linux镜像创建的ECS云服务器,可能存在NTP、YUM没有配置,还可能存在最近暴漏较高的安全漏洞。请按照本文中介绍的操作步骤进行修复,可以让您的云服务器更加安全,可以使用免费的阿里云提供的NTP进行时间同步,还可以使用阿里云提供的YUM服务进行安装软件。

解决方案

阿里云提醒您:

  • 如果您对实例或数据有修改、变更等风险操作,务必注意实例的容灾、容错能力,确保数据安全。
  • 如果您对实例(包括但不限于ECS、RDS)等进行配置与数据修改,建议提前创建快照或开启RDS日志备份等功能。
  • 如果您在阿里云平台授权或者提交过登录账号、密码等安全信息,建议您及时修改。

配置NTP

提示:此步骤不区分系统的发行版本。

首先备份/etc/ntp.conf文件,然后将其内容替换为如下所示。

# ntp.conf
#
# ntpd config for aliyun ecs.
#
# 6LAN+6LAN+3WAN
#               shijun.cao@alibaba-inc.com
#               2014.8.11
#
driftfile  /var/lib/ntp/drift
pidfile   /var/run/ntpd.pid
logfile /var/log/ntp.log
# Access Control Support
restrict    default ignore
restrict -6 default ignore
restrict 127.0.0.1
restrict 192.168.0.0 mask 255.255.0.0 nomodify notrap nopeer noquery
restrict 172.16.0.0 mask 255.240.0.0 nomodify notrap nopeer noquery
restrict 100.64.0.0 mask 255.192.0.0 nomodify notrap nopeer noquery
restrict 10.0.0.0 mask 255.0.0.0 nomodify notrap nopeer noquery
restrict ntp1.aliyun.com nomodify notrap nopeer noquery
restrict ntp2.aliyun.com nomodify notrap nopeer noquery
restrict ntp3.aliyun.com nomodify notrap nopeer noquery
restrict ntp4.aliyun.com nomodify notrap nopeer noquery
restrict ntp5.aliyun.com nomodify notrap nopeer noquery
restrict ntp6.aliyun.com nomodify notrap nopeer noquery
# local clock
server 127.127.1.0
fudge  127.127.1.0 stratum 10
#public ntp server
server ntp1.aliyun.com iburst minpoll 4 maxpoll 10
server ntp2.aliyun.com iburst minpoll 4 maxpoll 10
server ntp3.aliyun.com iburst minpoll 4 maxpoll 10
server ntp4.aliyun.com iburst minpoll 4 maxpoll 10
server ntp5.aliyun.com iburst minpoll 4 maxpoll 10
server ntp6.aliyun.com iburst minpoll 4 maxpoll 10
#Private ntp server
server ntp1.cloud.aliyuncs.com iburst minpoll 4 maxpoll 10
server ntp2.cloud.aliyuncs.com iburst minpoll 4 maxpoll 10
server ntp3.cloud.aliyuncs.com iburst minpoll 4 maxpoll 10
server ntp4.cloud.aliyuncs.com iburst minpoll 4 maxpoll 10
server ntp5.cloud.aliyuncs.com iburst minpoll 4 maxpoll 10
server ntp6.cloud.aliyuncs.com iburst minpoll 4 maxpoll 10
#New private ntp server
server ntp7.cloud.aliyuncs.com iburst minpoll 4 maxpoll 10
server ntp8.cloud.aliyuncs.com iburst minpoll 4 maxpoll 10
server ntp9.cloud.aliyuncs.com iburst minpoll 4 maxpoll 10
server ntp10.cloud.aliyuncs.com iburst minpoll 4 maxpoll 10
server ntp11.cloud.aliyuncs.com iburst minpoll 4 maxpoll 10
server ntp12.cloud.aliyuncs.com iburst minpoll 4 maxpoll 10

更新软件源

说明:CentOS 6与CentOS 8操作系统版本结束了生命周期(EOL),按照社区规则,CentOS 6/8的源地址内容已移除。当您在CentOS 6/8系统内继续使用默认配置的源地址时会发生报错。建议您先切换CentOS 6/8的源地址,然后再进行操作。具体操作,请参见CentOS 6 EOL如何切换源?CentOS 8 EOL如何切换源?

  1. 选择如下任意一种方法,确认镜像当前的Linux系统发行版本。
    • 执行lsb_release -a命令,查看Linux系统发行版本。
    • 执行cat /etc/issue命令,查看Linux系统发行版本。
  2. CentOS系统。备份/etc/yum.repos.d/目录下的CentOS-Base.repo和epel.repo文件。根据CentOS系统版本,执行如下相应的命令,下载repo文件,然后执行yum makecache命令即可。
    1. CentOS 5
      wget -qO /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-5.repo
      wget -qO /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-5.repo
    2. CentOS 6
      wget -qO /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
      wget -qO /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo
    3. CentOS 7
      wget -qO /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
      wget -qO /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
  3. Aliyun 5.7系统。备份/etc/yum.repos.d/CentOS-Base.repo文件后,执行如下命令,下载repo文件,然后执行yum makecache命令即可。
    wget -qO /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/aliyun-5.repo
  4. Ubuntu系统。备份/etc/apt/sources.list文件,然后根据发行版版本,执行如下相应的命令,下载repo文件,然后执行apt-get update命令即可。
    1. Ubuntu 12.04
      wget -qO /etc/apt/sources.list http://mirrors.aliyun.com/repo/ubuntu1204-lts.list
    2. Ubuntu 14.04
      wget -qO /etc/apt/sources.list http://mirrors.aliyun.com/repo/ubuntu1404-lts.list
  5. Debian系统。备份/etc/apt/sources.list文件。然后根据发行版版本,执行如下相应的命令,下载repo文件,然后执行apt-get update命令即可。
    1. Debian 6
      wget -qO /etc/apt/sources.list http://mirrors.aliyun.com/repo/debian6-lts.list
    2. Debian 7
      wget -qO /etc/apt/sources.list http://mirrors.aliyun.com/repo/debian7-lts.list

安全漏洞修复

修复目前已知软件的重大安全漏洞,需要升级软件包,升级的软件包括bash、glibc、openssl、wget、ntp。

在执行如下命令之前,需要确保系统当前的软件源已经设置正确。

  • 对于CentOS和Aliyun系统,执行如下命令。
    yum update bash glibc openssl wget ntp
  • 对于Ubuntu和Debian系统,执行如下命令。
    apt-get install bash libc6 libc-bin openssl wget ntp

适用于

  • 云服务器ECS