服务器扫描出一些中危漏洞,必须要修复下面zlib,openssh和openssl升级顺序一定要正确
查看zlib现有版本
[root@node1 ~]# find / -name zlib.pc
/usr/lib64/pkgconfig/zlib.pc
[root@node1 ~]# cat /usr/lib64/pkgconfig/zlib.pc
prefix=/usr
exec_prefix=${prefix}
libdir=/usr/lib64
sharedlibdir=${libdir}
includedir=/usr/include
Name: zlib
Description: zlib compression library
Version: 1.2.7
Requires:
Libs: -L${libdir} -L${sharedlibdir} -lz
Cflags: -I${includedir}
安装最新zlib:
yum -y install gcc*
wget http://www.zlib.net/zlib-1.2.11.tar.gz
tar xf zlib-1.2.11.tar.gz
cd zlib-1.2.11
./configure && make test && make install && make clean
./configure --shared && make test && make install
cp zutil.h /usr/local/include/
cp zutil.c /usr/local/include/
#查看新旧版本各存放路径:
[root@localhost zlib-1.2.11]# find / -name zlib.pc
/root/zlib-1.2.11/zlib.pc
/usr/local/lib/pkgconfig/zlib.pc
调用新版本:
vim /etc/ld.so.conf
include ld.so.conf.d/*.conf
/usr/local/lib/ #加入这一行
替换新版本到系统指定目录下:
cp -rp /usr/local/lib/* /usr/lib64/
mv /usr/lib64/libz.so.1.2.7
cd /usr/lib64
mv libz.so /tmp/
ln -s libz.so.1.2.11 libz.so
加载:ldconfig
查看动态库链接:
ldconfig -v |grep libz
卸载旧版本zlib:
[root@localhost zlib-1.2.11]# rpm -aq |grep zlib
zlib-1.2.7-18.el7.x86_64
[root@localhost zlib-1.2.11]# rpm -e --nodeps zlib-1.2.7-18.el7.x86_64
#测试php,需要lamp环境,下面是脚本一键安装lamp:
https://mp.csdn.net/postedit/83090003
#如果是centos7要把里面的yum -y mysql改成mariadb*;systemctl start mariadb
默认yum装完lamp会自动装上zlib,还需要再卸载一次。
最后浏览器访问:http://10.24.45.11/test.php
往下面找zlib模块
查看现有版本:ssh -V
OpenSSH_7.4p1, OpenSSL 1.0.2k-fips 26 Jan 2017
1、安装依赖
yum install -y pam-devel rpm-build openssl-devel
#注意yum安装openssl-devel的时候会重新把旧版本zlib安装上去,记得卸载。
2、下载安装包
wget http://ftp.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-7.8p1.tar.gz
3、卸载原Openssh
# rpm -qa |grep openssh
#openssh-clients-7.4p1-16.el7.x86_64
#openssh-7.4p1-16.el7.x86_64
#openssh-server-7.4p1-16.el7.x86_64
下面这步很重要
for i in $(rpm -qa |grep openssh);do rpm -e $i --nodeps;done
4、解压openssh安装包
tar -zxvf openssh-7.8p1.tar.gz
cd openssh-7.8p1
5、编译安装
./configure --prefix=/usr --sysconfdir=/etc/ssh --with-md5-passwords--with-pam--with-tcp-wrappers --with-ssl-dir=/usr/local/ssl --without-hardening
rm -rf /etc/ssh #注意这一步一定要执行
make && make install
6、安装完成,执行配置
cp contrib/redhat/sshd.init /etc/init.d/sshd
chkconfig --add sshd
chkconfig sshd on
sed -i "32a PermitRootLogin yes" /etc/ssh/sshd_config
systemctl restart sshd
7、查看升级后的版本
[root@Log openssh-7.8p1]# ssh -V
OpenSSH_7.8p1, OpenSSL 1.0.2k-fips 26 Jan 2017
openssl version -a #查看现有版本
wget https://www.openssl.org/source/openssl-1.1.1b.tar.gz
tar xf openssl-1.1.1b.tar.gz
cd openssl-1.1.1b
./config shared zlib
make && make install
编译完了要加载动态库文件:ldconfig
[root@localhost openssl-1.1.1b]# find / -name openssl
/etc/pki/ca-trust/extracted/openssl
/root/openssl-1.1.1b/apps/openssl
/root/openssl-1.1.1b/include/openssl
/root/openssl-1.1.1b/test/ossl_shim/include/openssl
/usr/bin/openssl
/usr/lib64/openssl
/usr/include/openssl
/usr/local/bin/openssl
/usr/local/include/openssl
/usr/local/share/doc/openssl
再查看openssl版本:
[root@node2 openssl-1.1.1b]# openssl version
报错如下:
openssl: error while loading shared libraries: libssl.so.1.1: cannot open shared object file: No such file or directory
解决方法:
[root@node2 openssl-1.1.1b]# find / -name libssl.so.1.1
/root/openssl-1.1.1b/libssl.so.1.1
/usr/local/lib64/libssl.so.1.1
执行下面两步:
ln -s /usr/local/lib64/libssl.so.1.1 /usr/lib64/libssl.so.1.1
ln -s /usr/local/lib64/libcrypto.so.1.1 /usr/lib64/libcrypto.so.1.1
[root@node2 openssl-1.1.1b]# openssl version
OpenSSL 1.1.1b 26 Feb 2019