首頁  >  文章  >  運維  >  如何對於歷史Linux鏡像的問題進行修復處理

如何對於歷史Linux鏡像的問題進行修復處理

坏嘻嘻
坏嘻嘻轉載
2018-09-30 14:01:532238瀏覽

本文在介紹如何對歷史Linux鏡像的問題進行修復處理的基礎上,重點探討了其具體步驟,本文內容緊湊,希望大家可以有所收穫。

歷史Linux鏡像的問題修復方案

歷史Linux映像建立的ECS雲端伺服器,可能有NTP沒有配置,YUM沒有配置,也可能有最近暴漏較高的安全漏洞,請依照以下步驟進行修復,可以讓您的雲端伺服器更加安全,還可以使用阿里雲提供的YUM服務進行安裝軟體,可以使用免費的阿里雲提供的NTP進行時間同步。

1. 設定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

2. 更新軟體來源

#0 . 先確認鏡像目前的Linux 系統發行版和版本號。

如果有lsb_release 指令,執行:

lsb_release -a

否則執行

cat /etc/issue

1 . 對於CentOS,備份/etc/yum.repos.d/下的CentOS-Base.repo 和epel.repo 文件,根據CentOS 版本,執行如下相應的命令:

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

repo 檔案下載完成後,執行:

yum makecache

2 . 對於Aliyun 5.7,備份/etc/yum.repos.d/CentOS-Base.repo ,然後執行:

wget -qO /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/aliyun-5.repo

repo 檔案下載完成後,執行:

yum makecache

3 . 對於Ubuntu,備份/etc/apt/sources.list 文件,根據發行版版本,執行命令:

ubuntu12.04:
wget -qO  /etc/apt/sources.list http://mirrors.aliyun.com/repo/ubuntu1204-lts.list
ubuntu14.04:
wget -qO  /etc/apt/sources.list http://mirrors.aliyun.com/repo/ubuntu1404-lts.list

然後執行:

apt-get update

4 . 對於Debian,備份/etc/apt/sources.list 文件,根據發行版版本,執行命令:

debian6:
wget -qO /etc/apt/sources.list http://mirrors.aliyun.com/repo/debian6-lts.list
debian7:
wget -qO /etc/apt/sources.list http://mirrors.aliyun.com/repo/debian7-lts.list

然後執行:

apt-get update

3. 安全漏洞修復修補程式

#主要修復目前已知的重大安全漏洞,需要升級的軟體包括: bash 、glibc 、 openssl 、 wget 、ntp 。

在執行以下命令之前,需要確保系統目前的軟體來源已經設定正確。

1 . 對於 CentOS 和 Aliyun Linux,執行:

yum update bash glibc openssl wget ntp

2 . 對於 Ubuntu 和 Debian,執行:

apt-get install bash libc6 libc-bin openssl wget ntp

以上是如何對於歷史Linux鏡像的問題進行修復處理的詳細內容。更多資訊請關注PHP中文網其他相關文章!

陳述:
本文轉載於:aliyun.com。如有侵權,請聯絡admin@php.cn刪除