歷史Linux鏡像的問(wèn)題的修復(fù)方案
發(fā)布時(shí)間:2021-02-01 點(diǎn)擊數(shù):643
問(wèn)題描述
歷史Linux鏡像創(chuàng)建的ECS云服務(wù)器,可能存在NTP、YUM沒(méi)有配置,還可能存在最近暴漏較高的安全漏洞。請(qǐng)按照本文中介紹的操作步驟進(jìn)行修復(fù),可以讓您的云服務(wù)器更加安全,可以使用免費(fèi)的阿里云提供的NTP進(jìn)行時(shí)間同步,還可以使用阿里云提供的YUM服務(wù)進(jìn)行安裝軟件。
解決方案
- 如果您對(duì)實(shí)例或數(shù)據(jù)有修改、變更等風(fēng)險(xiǎn)操作,務(wù)必注意實(shí)例的容災(zāi)、容錯(cuò)能力,確保數(shù)據(jù)安全。
- 如果您對(duì)實(shí)例(包括但不限于ECS、RDS)等進(jìn)行配置與數(shù)據(jù)修改,建議提前創(chuàng)建快照或開(kāi)啟RDS日志備份等功能。
- 如果您在阿里云平臺(tái)授權(quán)或者提交過(guò)登錄賬號(hào)、密碼等安全信息,建議您及時(shí)修改。
配置NTP
提示:此步驟不區(qū)分系統(tǒng)的發(fā)行版本。
首先備份/etc/ntp.conf文件,然后將其內(nèi)容替換為如下所示。
# 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
更新軟件源
-
選擇如下任意一種方法,確認(rèn)鏡像當(dāng)前的Linux系統(tǒng)發(fā)行版本。
- 執(zhí)行l(wèi)sb_release -a命令,查看Linux系統(tǒng)發(fā)行版本。
- 執(zhí)行cat /etc/issue命令,查看Linux系統(tǒng)發(fā)行版本。
-
CentOS系統(tǒng)。備份/etc/yum.repos.d/目錄下的CentOS-Base.repo和epel.repo文件。根據(jù)CentOS系統(tǒng)版本,執(zhí)行如下相應(yīng)的命令,下載repo文件,然后執(zhí)行yum
makecache命令即可。
-
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
-
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
-
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
-
CentOS 5
-
Aliyun 5.7系統(tǒng)。備份/etc/yum.repos.d/CentOS-Base.repo文件后,執(zhí)行如下命令,下載repo文件,然后執(zhí)行yum
makecache命令即可。
wget -qO /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/aliyun-5.repo
-
Ubuntu系統(tǒng)。備份/etc/apt/sources.list文件,然后根據(jù)發(fā)行版版本,執(zhí)行如下相應(yīng)的命令,下載repo文件,然后執(zhí)行apt-get
update命令即可。
-
Ubuntu 12.04
wget -qO /etc/apt/sources.list http://mirrors.aliyun.com/repo/ubuntu1204-lts.list
-
Ubuntu 14.04
wget -qO /etc/apt/sources.list http://mirrors.aliyun.com/repo/ubuntu1404-lts.list
-
Ubuntu 12.04
-
Debian系統(tǒng)。備份/etc/apt/sources.list文件。然后根據(jù)發(fā)行版版本,執(zhí)行如下相應(yīng)的命令,下載repo文件,然后執(zhí)行apt-get
update命令即可。
-
Debian 6
wget -qO /etc/apt/sources.list http://mirrors.aliyun.com/repo/debian6-lts.list
-
Debian 7
wget -qO /etc/apt/sources.list http://mirrors.aliyun.com/repo/debian7-lts.list
-
Debian 6
安全漏洞修復(fù)
修復(fù)目前已知軟件的重大安全漏洞,需要升級(jí)軟件包,升級(jí)的軟件包括bash、glibc、openssl、wget、ntp。
在執(zhí)行如下命令之前,需要確保系統(tǒng)當(dāng)前的軟件源已經(jīng)設(shè)置正確。
-
對(duì)于CentOS和Aliyun系統(tǒng),執(zhí)行如下命令。
yum update bash glibc openssl wget ntp
-
對(duì)于Ubuntu和Debian系統(tǒng),執(zhí)行如下命令。
apt-get install bash libc6 libc-bin openssl wget ntp
適用于
- 云服務(wù)器 ECS
如果您有其他問(wèn)題,可以聯(lián)系北京志遠(yuǎn)天成阿里云代理商,為您提供一對(duì)一專(zhuān)業(yè)全面的技術(shù)服務(wù),同時(shí)新老阿里云會(huì)員,均可享受我公司代理商價(jià)格,歡迎咨詢!

