centos7.9编译升级openssl和openssh9.9p1的记录(intel X86、海光C86双架构)


前言

手上有个项目的centos7.9机器漏扫发现了openssl和openssh的问题,得手动升级一下。只能说有条件的话,业务节点还是直接上ubuntu比较安逸。
增加记录一下升级到openssh9.9p1的记录,包含intel X86和海光C86两种架构


一、漏洞列表

OpenSSH 用户枚举漏洞-CVE-2018-15473

在这里插入图片描述

OpenSSH’sftp-server’安全绕过漏洞

在这里插入图片描述

OpenSSH 用户枚举漏洞-CVE-2018-15919

在这里插入图片描述

SSH弱加密算法支持

在这里插入图片描述

二、升级openssl

按照漏洞要求,准备升级openssl到OpenSSL_1_1_1w版本

1.更换yum源到阿里云并安装编译环境包

# 备份repo文件
mkdir -p /etc/yum.repos.d/CentOS-Base.repo.backup;
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup;
# 获取阿里云的repo文件
curl  -o  /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
yum makecache;
yum install wget -y;
# 获取epel的repo文件
wget -O /etc/yum.repos.d/epel-7.repo http://mirrors.aliyun.com/repo/epel-7.repo;
yum -y install epel-release;
#安装编译基础包
yum install -y gcc make zlib-devel pam-devel lrzsz

2.备份原有文件

mv /usr/bin/openssl /usr/bin/openssl.old
mv /usr/include/openssl /usr/include/openssl.old

3.下载源码包并编译

# 下载并解压
cd /root/ && wget https://github.com/openssl/openssl/releases/download/OpenSSL_1_1_1w/openssl-1.1.1w.tar.gz
tar -xvf openssl-1.1.1w.tar.gz
cd /root/openssl-1.1.1w/
# 编译安装
./config --prefix=/usr/local/openssl --openssldir=/usr/local/openssl

make && make install

4.新版本文件的替换

# 更新库文件路径、库缓存
echo "/usr/local/openssl/lib" >/etc/ld.so.conf.d/openssl_1.1.1.conf
ldconfig
# 更新openssl库
ln -s /usr/local/openssl/bin/openssl /usr/bin/openssl
ln -s /usr/local/openssl/include/openssl /usr/include/openssl

4.看成版本

openssl version

在这里插入图片描述


二、升级openssh-7.9p1版本

按照漏洞要求,准备升级openssh到openssh-7.9p1版本

1.安装telnet防止失联

yum install -y telnet-server xinetd 
systemctl start telnet.socket && systemctl start xinetd
echo 'pts/0'>>/etc/securetty && echo 'pts/1'>>/etc/securetty
systemctl restart telnet.socket

2.卸载已有openssh软件包

yum remove -y openssh

3.下载源码包并编译

# 下载并解压
cd /root/ && wget https://mirrors.aliyun.com/pub/OpenBSD/OpenSSH/portable/openssh-7.9p1.tar.gz
tar -xvf openssh-7.9p1.tar.gz
cd /root/openssh-7.9p1
# 编译安装
./configure --prefix=/usr --sysconfdir=/etc/ssh --with-ssl-dir=/usr/local/openssl --with-zlib  --with-pam --with-md5-passwords

make && make install
# 等待出现权限问题后调整权限
chmod 600 /etc/ssh/ssh_host_ecdsa_key /etc/ssh/ssh_host_ed25519_key /etc/ssh/ssh_host_rsa_key
# 调整之后再次执行
make && make install

4.创建service文件

cp /root/openssh-7.9p1/contrib/redhat/sshd.init /etc/init.d/sshd
chmod u+x /etc/init.d/sshd
chkconfig --add sshd

5.追加root登陆并重启服务

echo "PermitRootLogin yes" >> /etc/ssh/sshd_config

service sshd restart 
ssh -V

在这里插入图片描述

二、升级openssh-9.9p1版本(intel X86和海光C86两种架构)

按照漏洞要求,准备升级openssh到openssh-9.9p1版本
海光架构就用阿里云的源安装编译环境就行

1.安装telnet防止失联

yum install -y telnet-server xinetd 
systemctl start telnet.socket && systemctl start xinetd
echo 'pts/0'>>/etc/securetty && echo 'pts/1'>>/etc/securetty
systemctl restart telnet.socket

2.卸载已有openssh软件包

yum remove -y openssh

3.下载源码包并编译

# 下载并解压
cd /root/ && wget https://mirrors.aliyun.com/pub/OpenBSD/OpenSSH/portable/openssh-9.9p1.tar.gz
tar -xvf openssh-9.9p1.tar.gz
cd /root/openssh-9.9p1
# 编译安装
./configure --prefix=/usr --sysconfdir=/etc/ssh --with-ssl-dir=/usr/local/openssl --with-zlib  --with-pam --with-md5-passwords

make && make install
# 等待出现权限问题后调整权限
chmod 600 /etc/ssh/ssh_host_ecdsa_key /etc/ssh/ssh_host_ed25519_key /etc/ssh/ssh_host_rsa_key
# 调整之后再次执行
make && make install

4.创建service文件

cp /root/openssh-9.9p1/contrib/redhat/sshd.init /etc/init.d/sshd
chmod u+x /etc/init.d/sshd
chkconfig --add sshd

5.追加root登陆并重启服务

echo "PermitRootLogin yes" >> /etc/ssh/sshd_config

service sshd restart 
ssh -V

总结

简单记录一下centos7.9升级openssl和openssh的过程,有条件的话还是使用ubuntu LTS的操作系统更合适

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值