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

作者:laozhang 时间:2023-08-19 08:53:40 

历史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,镜像,修复
0
投稿

猜你喜欢

  • 黑客攻破SQL服务器系统的十种方法

    2009-05-07 17:07:00
  • 如何申请Google AdSense

    2007-08-18 10:46:00
  • 和蜘蛛搞好关系 三招让网站收录量大提升

    2009-01-20 14:26:00
  • Linux中logrotate日志轮询操作总结

    2023-06-21 20:25:46
  • DEDECMS:TAG作为文章发布后关键字meta keywords的修改办法

    2009-02-13 17:22:00
  • 投放google adwords广告如何留住客户信息经验谈

    2010-05-10 15:48:00
  • WordPress博客推广之Gravatar头像设置

    2011-07-27 18:18:31
  • Google官方:按照AdSense要求投放广告代码

    2009-01-20 13:08:00
  • 中关村寻宝:中国式管理书籍为何被放在小角落?

    2009-10-23 09:44:00
  • 购买链接的一些评定标准和购买规则

    2009-07-10 10:28:00
  • Linux watch命令的使用

    2023-11-03 03:44:18
  • 网赚里面火热而常见的骗术

    2010-05-10 11:20:00
  • Discuz的可定制性及插件简析

    2009-02-20 16:03:00
  • NETWARE服务器随机存储器的扩展

    2010-05-13 18:09:00
  • Discuz X链接伪静态的.htaccess重定向规则

    2011-08-18 18:31:05
  • 做站内容的选择与创意

    2008-05-30 12:52:00
  • 雅虎CEO巴茨讽刺Facebook 他们靠什么赚钱

    2010-03-08 09:12:00
  • QQ空间个人中心升级2.0 黄钻LV7优先体验中

    2009-10-28 16:02:00
  • 详解Linux指令文件覆盖和文件追加

    2023-08-26 02:02:33
  • Windows 2003 架设用户隔离FTP站点

    2009-12-22 19:20:00
  • asp之家 网站运营 m.aspxhome.com