解决NTPD漏洞,升级Ntpd版本

关于解决漏洞的问题我就不详说了,主要就是升级版本。这里我们就直接简单记录下步骤:

1、升级
使用root用户登录系统进入到/home/guankong ,上传ntp-4.2.8p9-1.el6.x86_64.rpm到该目录下

2.安装依赖包
yum install gcc gcc-c++ openssl-devel libstdc++* libcap*

3.备份旧版本的配置文件

 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

4.卸载旧的NTPD
yum erase ntp ntpdate

5.创建/var/lib/ntp目录
install -v -m710 -o ntp -g ntp -d /var/lib/ntp                //可能存在目录会报错


6.安装rpm包
rpm -i ntp-4.2.8p9-1.el6.x86_64.rpm

7.还原配置文件
cp /etc/init.d/ntpd.bak /etc/init.d/ntpd
cp /etc/sysconfig/ntpd.bak /etc/sysconfig/ntpd
cp /etc/sysconfig/ntpdate.bak /etc/sysconfig/ntpdate
mv /etc/ntp.bak /etc/ntp
cp /etc/ntp.conf.bak /etc/ntp.conf
 

shell脚本命令一键执行:

#!/bin/sh
chmod 755 -R .
install_log=install.log

##ntp upgrade
echo "#######1:ntp upgrade ..." 2>&1 | tee -a $install_log
\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 
yum -y erase ntp ntpdate 2>&1 | tee -a $install_log
rpm -i ntp-4.2.8p9-1.el6.x86_64.rpm 2>&1 | tee -a $install_log
\cp /etc/init.d/ntpd.bak /etc/init.d/ntpd 
\cp /etc/sysconfig/ntpd.bak /etc/sysconfig/ntpd 
\cp /etc/sysconfig/ntpdate.bak /etc/sysconfig/ntpdate 
rm /etc/ntp -rf
mv /etc/ntp.bak /etc/ntp
\cp /etc/ntp.conf.bak /etc/ntp.conf 
echo "ntp upgrade end !"   2>&1 | tee -a $install_log

需要文件:ntp-4.2.8p9-1.el6.x86_64.rpm,自行百度下载

posted @ 2017-04-19 17:10  望星辰大海  阅读(5900)  评论(0编辑  收藏  举报