NTP 4.2.6p5版本导致多个系统安全漏洞

问题描述:通过漏洞扫描发现NTP 4.2.6p5版本导致多个系统漏洞,需要升级版本更高的ntp,一般刚开始都是yum直接装ntp包,现在需要重新卸载安装源码包

下载链接:http://distfiles.macports.org/ntp/

操作系统:centos7.6

 

 

 

 

 扫描安全漏洞部分如下:

 

 

 1.查看当前ntp版本

[root@hzh ntp]# ntpd --version
ntpd 4.2.6p5

 

2.备份原ntp配置文件

cp -ar /etc/ntp /etc/ntp.bak
cp /etc/ntp.conf /etc/ntp.conf.bak
#cp /etc/init.d/ntpd /etc/init.d/ntpd.bak                     ---如果之前没有加入开机自启,这个是没有这个文件的
cp /etc/sysconfig/ntpd /etc/sysconfig/ntpd.bak
cp /etc/sysconfig/ntpdate /etc/sysconfig/ntpdate.bak

 

3.查看所需的rpm包(openssl-devel经过测试不需要这个包我也成功安装了,但是没有gcc的两个包不行)

rpm -qa gcc gcc-c++ openssl-devel libstdc++* libcap*

yum install gcc gcc-c++ openssl-devel libstdc++* libcap* -y

 

4.卸载原ntp服务

yum remove ntp ntpdate

 

5.上传ntp-4.2.8p12

mkdir /ntp

上传ntp-4.2.8p12.tar.gz

[root@hzh ntp]# tar -zxvf ntp-4.2.8p12.tar.gz

 

6.编译安装

cd /ntp/ntp-4.2.8p12

./configure \
--prefix=/usr \
--bindir=/usr/sbin \
--enable-all-clocks \
--enable-parse-clocks \
--docdir=/usr/share/doc/ntp-4.2.8p12

make &&make install

时间可能会比较长,需要等待3-5分钟

 

7.查看版本是否安装成功

[root@hzh ~]# ntpd --version
ntpd 4.2.8p12@1.3728 Mon Jul 20 10:58:24 UTC 2020 (1)

 

8.使用原ntp配置启动

cp /etc/ntp.conf.bak /etc/ntp.conf

/usr/sbin/ntpd -c /etc/ntp.conf                --启动ntp程序

 

9.查看ntp是否启动成功

ps -ef | grep ntpd

netstat -tunlp | grep 123

 

10.与时间同步服务器进行时间同步

netstat -tunlp | grep 123

 

kill -9 1802

ntpdate 192.168.226.8            --ntpdate跟上配好ntp的服务端

hwclock -w         --写入硬件

 

11.可选则将启动ntp写入定时任务或者添加脚本到开机自启动中

加入定时任务:

crontab -e
00 04 * * * /usr/sbin/ntpdate 时间同步服务器;/sbin/hwclock -w

 

加到开机自启动:

cd /etc/init.d
touch ntp_start.sh
cat > ntp_start.sh <<EOF
#!/bin/sh
#chkconfig: 2345 80 90
#description:开机自动启动的脚本程序
/usr/sbin/ntpd -c /etc/ntp.conf
EOF

chmod +x /etc/init.d/ntp_start.sh
chkconfig --add ntp_start.sh
chkconfig ntp_start.sh on

相关文章

文章浏览阅读1.8k次,点赞63次,收藏54次。Linux下的目录权限...
文章浏览阅读1.6k次,点赞44次,收藏38次。关于Qt的安装、Wi...
本文介绍了使用shell脚本编写一个 Hello
文章浏览阅读1.5k次,点赞37次,收藏43次。【Linux】初识Lin...
文章浏览阅读3k次,点赞34次,收藏156次。Linux超详细笔记,...
文章浏览阅读6.8k次,点赞109次,收藏114次。【Linux】 Open...