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的操作系统更合适

相关推荐
C澒8 分钟前
SGW 接入层运维实战:配置查看 + 监控分析 + 日志排查
前端·安全·运维开发
Noontec21 分钟前
铁威马F4-425Plus提供专属于创作者的解决方案
安全·网络存储·铁威马nas
emma羊羊1 小时前
【AI技术安全】
网络·人工智能·安全
赛德传动3 小时前
使用SNJ齿轮齿条升降机时,有哪些安全防护措施?
网络·安全·制造
拍客圈4 小时前
Discuz CC 防护规则
服务器·网络·安全
九河云4 小时前
数字韧性时代,华为云CBR为业务连续性注入“免疫基因”
大数据·人工智能·安全·机器学习·华为云
国科安芯5 小时前
航空级PMSM驱动系统中MCU的故障诊断与容错控制策略研究
单片机·嵌入式硬件·安全·架构·制造·安全性测试
C澒5 小时前
系统初始化成功率下降排查实践
前端·安全·运维开发
只是懒得想了5 小时前
C++实现密码破解工具:从MD5暴力破解到现代哈希安全实践
c++·算法·安全·哈希算法
云边云科技_云网融合5 小时前
AIoT智能物联网平台:架构解析与边缘应用新图景
大数据·网络·人工智能·安全