标签:sshd -- OpenSSH openssl etc ssh 版本 8.8 usr
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 <server_ip>
标签:sshd,--,OpenSSH,openssl,etc,ssh,版本,8.8,usr 来源: https://www.cnblogs.com/happy4java/p/15855312.html
本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享; 2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关; 3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关; 4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除; 5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。