栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 系统运维 > 运维 > Linux

升级OpenSSH版本(8.8版本)

Linux 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

升级OpenSSH版本(8.8版本)

1.前言
Hello大家好我是哈皮,最近项目中被报告低版本SSH存在漏洞,需要进行升级(升级到目前最新的8.8版本),记录一下升级过程。

2.资源
https://github.com/openssh/openssh-portable/tags
https://github.com/openssl/openssl/tags

我的版本

https://github.com/happyjava007/share/raw/main/openssh-8.8p1.tar.gz
https://github.com/happyjava007/share/raw/main/openssl-3.0.1.tar.gz
3.开启Telnet登陆
为了避免升级失败,导致无法登陆服务器,所以需要开启Telnet登陆。

systemctl start telnet.socket
telnet 127.0.0.1 # 测试是否可以正常登陆
4.升级OpenSSL

备份

mv /usr/bin/openssl /usr/bin/openssl_old

进入OpenSSL源码目录

./config shared && make && make install

检查安装

openssl version

报错 openssl: error while loading shared libraries: libssl.so.3: cannot open shared object file: No such file or directory 在OpenSSL源码目录

cp libssl.so.3 /usr/lib64/
cp libcrypto.so.3 /usr/lib64/
5.升级OpenSSH

备份

mkdir /etc/ssh_old
mv /etc/ssh/* /etc/ssh_old/

进入openssh目录

./configure --prefix=/usr/ --sysconfdir=/etc/ssh --with-ssl-dir=/usr/local/lib64/ --with-zlib --with-pam --with-md5-password --with-ssl-engine --with-selinux

警告

PAM is enabled. You may need to install a PAM control file
for sshd, otherwise password authentication may fail.
Example PAM control files can be found in the contrib/
subdirectory

ls contrib # 里面有各种系统

备份

mv /etc/pam.d/sshd /etc/pam.d/sshd_bak

复制

cp contrib/redhat/sshd.pam /etc/pam.d/sshd # 根据系统选择

安装

make && make install

根据提示执行

/usr/sbin/sshd -t -f /etc/ssh/sshd_config

vim /etc/ssh/sshd_config
PermitRootLogin yes # 开启root登陆

移除旧版本的文件

mv /usr/lib/systemd/system/sshd.service /etc/ssh_old/
mv /usr/lib/systemd/system/sshd.socket /etc/ssh_old/

cp -a contrib/redhat/sshd.init /etc/init.d/sshd

systemctl daemon-reload
systemctl restart sshd
升级完后,ssh登陆可能报错

Host key verification failed.
执行以下命令即可

ssh-keygen -R

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/836306.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号