openssh从7.9升到openssh8.6,openssl升到openssl1.1.1k[成功升级]

升级openssl到1.1.1k

前述

由于项目安全漏洞扫描显示OpenSSH版本过低需升级至最新版,今天已成功升级,并记录此次升级过程

查看当前版本
[root@minio3 ~]# ssh -V
OpenSSH_7.4p1, OpenSSL 1.0.2k-fips  26 Jan 2017
[root@minio3 ~]# cat /etc/redhat-release 
CentOS Linux release 7.6.1810 (Core) 
[root@minio3 ~]# 

升级前提(如果不安装升级依赖在校验的时候不会成功)

[root@localhost ~]# yum -y install wget gcc zlib-devel openssl-devel pam-devel libselinux-devel

openssl升到openssl1.1.1k

备份旧版openssl

[root@localhost ~]# mv /usr/bin/openssl usr/bin/openssl.bak
[root@localhost ~]# mv /usr/include/openssl /usr/include/openssl.bak
  • 下载方式
    • wget https://www.openssl.org/source/openssl-1.1.1k.tar.gz
    • 或者本地下载上传: https://www.openssl.org/source/openssl-1.1.1k.tar.gz

解压并编译安装

[root@localhost ~]# wget https://www.openssl.org/source/openssl-1.1.1k.tar.gz
[root@localhost ~]# tar zxf openssl-1.1.1k.tar.gz -C /usr/local/
[root@localhost ~]# cd /usr/local/openssl-1.1.1k/
[root@localhost openssl-1.1.1k]# ./config --prefix=/usr/local/openssl
[root@localhost openssl-1.1.1k]# make -j 2 && make install

配置调整

[root@localhost openssl-1.1.1k]# ln -s /usr/local/openssl/bin/openssl /usr/bin/openssl
[root@localhost openssl-1.1.1k]# ln -s /usr/local/openssl/include/openssl /usr/include/openssl
[root@localhost openssl-1.1.1k]# echo "/usr/local/openssl/lib" >> /etc/ld.so.conf
[root@localhost openssl-1.1.1k]# ldconfig -v

查看版本

[root@localhost openssl-1.1.1k]# openssl version
OpenSSL 1.1.1k  25 Mar 2021

openssh从7.9升到openssh8.6

  • 下载方式

停止原有服务及备份数据

[root@localhost ~]# systemctl stop sshd
[root@localhost ~]# mv /etc/ssh /etc/ssh.bak
[root@localhost ~]# mv /etc/pam.d/sshd /etc/pam.d/sshd.bak
卸载原有的openssh包(如果不支持yum,请先把包上传,不然卸载之后就没法上传)----注意

```java
[root@localhost ~]# rpm -e --nodeps `rpm -qa | grep openssh`

下载并解压安装包

[root@localhost ~]# wget https://cdn.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-8.6p1.tar.gz
[root@localhost ~]# tar zxf openssh-8.6p1.tar.gz 
[root@localhost ~]# cd openssh-8.6p1

编译安装

[root@localhost openssh-8.6p1]# ./configure --prefix=/usr --sysconfdir=/etc/ssh --with-md5-passwords --with-pam --with-zlib --with-tcp-wrappers --with-ssl-dir=/usr/local/openssl --without-hardening
[root@localhost openssh-8.6p1]# make -j 2 && make install

拷贝配置文件并启动

[root@localhost openssh-8.6p1]# cp contrib/redhat/sshd.init /etc/init.d/sshd
[root@localhost openssh-8.6p1]# mv /etc/pam.d/sshd.bak /etc/pam.d/sshd
[root@localhost openssh-8.6p1]# mv /etc/ssh /etc/ssh_update.bak
[root@localhost openssh-8.6p1]# mv /etc/ssh.bak /etc/ssh
[root@localhost openssh-8.6p1]# chmod 600 /etc/ssh/*key
[root@localhost openssh-8.6p1]# chkconfig --add sshd
[root@localhost openssh-8.6p1]# chkconfig sshd on
[root@localhost openssh-8.6p1]# systemctl restart sshd

允许Root登陆

[root@localhost ~]# sed -i 's/^#\(PermitRootLogin \).*/\1yes/' /etc/ssh/sshd_config

版本验证

[root@localhost openssh-8.6p1]# ssh -V
OpenSSH_8.6p1, OpenSSL 1.1.1k  25 Mar 2021

使用命令
ssh -V、 sshd-V、 openssl version、 systemctl status sshd.service

如果升级之后发现使用root登陆不上的时候
修改 vi /etc/selinux/config
SELINUX=disabled
即可,
可以重新启动一下网卡(本人觉得没啥必要)
systemctl resstart network

大多数内容来自博客:本人在操作的时候主要参考此博客
https://blog.csdn.net/wh1007126468/article/details/118524812
除以上问题之外:我总结一下我的问题:

第一次安装完之后openssh 成功了,但是使用ssh -V 查看,之后发现

[root@localhost openssh-8.6p1]# ssh -V
OpenSSH_8.6p1, OpenSSL 1.0.1k  25 Mar 2021

openssl还是之前的版本,解决此问题版本,

  1. 先查看openssl是否安装成功,我问题是我安装成功了,但是好像又还原回去了,所以,重新编译一下openssl,确定成功安装
  2. 然后再重新执行opensshd的编译操作,发现成功了
./configure --prefix=/usr/ --sysconfdir=/etc/ssh --with-openssl-includes=/usr/local/ssl/include/ --with-ssl-dir=/usr/local/ssl/ --with-zlib --with-md5-passwords --with-pam && make && make install

出现这个问题:
安装这个即可
yum -y install pam-devel

yum安装问题
Another app is currently holding the yum lock; waiting for it to exit…
多半是卡住了:
ps aux|grep yum 查看已经启用的
然后都kill -9 pid 掉
再重新安装即可

最后还是启动升级完毕。有问题提出来,大家以起进步,最后感谢我参考的博客,上面已有链接。

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值