服务器之家:专注于VPS、云服务器配置技术及软件下载分享
分类导航

Linux|Centos|Ubuntu|系统进程|Fedora|注册表|Bios|Solaris|Windows7|Windows10|Windows11|windows server|

服务器之家 - 服务器系统 - Linux - 历史Linux镜像处理及修复方案

历史Linux镜像处理及修复方案

2022-07-27 08:44Linux教程网 Linux

在本文中我们给大家整理了关于如何对于历史Linux镜像的问题进行修复处理的相关内容,有需要的朋友们参考下。

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

1. 配置NTP

不区分发行版,先备份 /etc/ntp.conf,然后将其内容替换为如下:

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# 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 命令,执行:

?
1
lsb_release -a

否则执行

?
1
cat /etc/issue

1 . 对于 CentOS,备份 /etc/yum.repos.d/ 下的 CentOS-Base.repo 和 epel.repo 文件,根据 CentOS 版本,执行如下相应的命令:

CentOS 5:

?
1
2
3
4
5
6
7
8
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 文件下载完成后,执行:

?
1
yum makecache

2 . 对于 Aliyun 5.7,备份 /etc/yum.repos.d/CentOS-Base.repo ,然后执行:

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

repo 文件下载完成后,执行:

?
1
yum makecache

3 . 对于 Ubuntu,备份 /etc/apt/sources.list 文件,根据发行版版本,执行命令:

?
1
2
3
4
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

然后执行:

?
1
apt-get update

4 . 对于 Debian,备份 /etc/apt/sources.list 文件,根据发行版版本,执行命令:

?
1
2
3
4
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

然后执行:

?
1
apt-get update

3. 安全漏洞修复补丁

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

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

1 . 对于 CentOS 和 Aliyun Linux,执行:

?
1
yum update bash glibc openssl wget ntp

2 . 对于 Ubuntu 和 Debian,执行:

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

延伸 · 阅读

精彩推荐
  • Linuxlinux批量操作时提示Argument list too long解决方法

    linux批量操作时提示Argument list too long解决方法

    在实际使用过程中,若一个目录下文件或文件夹太多,在执行“*” 命令时 会提示Argument list too long,如rm -rf /tmp/*命令下...

    脚本之家2712019-06-03
  • LinuxXen VPS下添加swap交换分区的方法

    Xen VPS下添加swap交换分区的方法

    Xen VPS下添加swap交换分区的方法,需要的朋友可以参考下。 ...

    Linux教程网3092020-03-21
  • Linux详解在Linux下9个有用的touch命令示例

    详解在Linux下9个有用的touch命令示例

    本篇文章主要介绍了详解在Linux下9个有用的touch命令示例,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧...

    MjSeven7542022-03-09
  • LinuxLinux中改变文件权限的chmod命令详析

    Linux中改变文件权限的chmod命令详析

    在 Linux 命令中,chmod用于修改文件或者目录的权限。下面这篇文章主要给大家介绍了关于Linux中改变文件权限的chmod命令的相关资料,文中通过示例代码介绍...

    虎书博客7642022-07-07
  • Linuxlinux怎么让让垃圾文件自己消失?

    linux怎么让让垃圾文件自己消失?

    linux怎么让让垃圾文件自己消失?我们的文件总是越用越多,慢慢地我们的磁盘就被塞满了。这时, 我们不得不花费数个小时对我们的文件进行一一地盘点...

    百度经验4822019-10-08
  • Linux如何用 Bash 读写文件

    如何用 Bash 读写文件

    当你使用 Bash 编写脚本时,有时你需要从一个文件中读取数据或向一个文件写入数据。有时文件可能包含配置选项,而另一些时候这个文件是你的用户用你...

    Linux中国10862021-04-02
  • LinuxLinux查看文件内容、创建、查看软硬链接命令示例

    Linux查看文件内容、创建、查看软硬链接命令示例

    查看文件内容、创建软连接、创建硬链接等命令在操作过程中还是比较常见的,具体示例如下,感兴趣的朋友可以参考下,希望可以帮助到你 ...

    Linux教程网14322019-12-03
  • Linux干货:3个Linux性能监控和优化命令详解

    干货:3个Linux性能监控和优化命令详解

    小编为大家整理出了三个有关Linux性能监控和优化命令详细讲解,别看只有三个,但不影响他噎啊,本篇文章很长,涉及top命令、free命令和vmstat命令,真的...

    高效运维7002021-03-16