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

相关推荐
视觉&物联智能1 天前
【杂谈】-人工智能风险文化对组织决策的深远影响
人工智能·安全·ai·agi
cczixun1 天前
OpenAI连发GPT-5.5系列:免费版幻觉大降,安全版能力飙升,千亿融资估值直冲8520亿美元
人工智能·gpt·安全
@insist1231 天前
信息安全工程师-网络安全审计产品图谱与实战应用全解
网络·安全·软考·信息安全工程师·软件水平考试
m0_738120721 天前
应急响应(重点)——记一次某公司流量应急溯源分析(附带下载链接)
服务器·前端·数据库·安全·web安全·网络安全
大大大大晴天️1 天前
浅聊Hadoop集群的主流安全方案(LDAP+Kerberos+Ranger)
大数据·hadoop·安全
其实防守也摸鱼1 天前
无线网络安全--实验 规避WLAN验证之发现隐藏的SSID
java·开发语言·网络·安全·web安全·智能路由器·无线网络安全
SuperherRo1 天前
服务攻防-Java组件安全&FastJson&高版本JNDI&不出网C3P0&编码绕WAF&写入文件CI链
java·安全·fastjson·waf·不出网·高版本·写入文件
MY_TEUCK1 天前
【Git 实习生小白专用】:最安全、永不翻车、公司最爱 的标准版本控制工作流程
git·安全·github
yezannnnnn1 天前
AI Agent又删我数据库?我直接写了个安全拦截器(附项目源码)
安全·agent·claude
雪碧聊技术1 天前
上午题_信息安全
安全