centos7.9编译升级openssl和openssh的记录

文章目录


前言

手上有个项目的centos7.9机器漏扫发现了openssl和openssh的问题,得手动升级一下。只能说有条件的话,业务节点还是直接上ubuntu比较安逸。


一、漏洞列表

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

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

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

SSH弱加密算法支持

二、升级openssl

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

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

shell 复制代码
# 备份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.备份原有文件

shell 复制代码
mv /usr/bin/openssl /usr/bin/openssl.old
mv /usr/include/openssl /usr/include/openssl.old

3.下载源码包并编译

shell 复制代码
# 下载并解压
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.新版本文件的替换

shell 复制代码
# 更新库文件路径、库缓存
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.看成版本

shell 复制代码
openssl version

二、升级openssh

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

1.安装telnet防止失联

shell 复制代码
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软件包

shell 复制代码
yum remove -y openssh

3.下载源码包并编译

shell 复制代码
# 下载并解压
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文件

shell 复制代码
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登陆并重启服务

shell 复制代码
echo "PermitRootLogin yes" >> /etc/ssh/sshd_config

service sshd restart 
ssh -V

总结

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

相关推荐
天行健,君子而铎8 小时前
数据分类分级的范式转换:从规则匹配到场景化高准确率一键部署
网络·数据库·安全
砚凝霜9 小时前
【软考信息安全】第十章 入侵检测概述与原理分类
人工智能·安全·数据挖掘
Hum8le14 小时前
漏洞知识点《php伪协议》
开发语言·安全·web安全·php
砚凝霜14 小时前
【软考信息安全】第十九章 Unix/Linux安全分析与防护
linux·安全·unix
虹科网络安全16 小时前
“顶会”看安全(十九):医疗 AI 中的差异化隐私风险
人工智能·经验分享·安全
砚凝霜16 小时前
【软考信息安全】第十六章 网络安全风险评估过程与技术方法
网络·安全·web安全
步行cgn17 小时前
Spring AOP 实战:安全日志
python·安全·spring
Fxrain19 小时前
[Paper-Reading] CUAs 安全与隐私威胁综述
人工智能·安全·agent·智能体
砚凝霜21 小时前
【软考信息安全】第十七章 网络安全应急响应概述与事件处理流程
网络·安全·web安全
终端安全笔记1 天前
配置锁状态那一栏查的是什么:报告里几项各自指向什么风险
android·前端·安全·ios