centos7.9离线升级openssl和openssh9.2

1、查看本机ssh版本

ssh -V

OpenSSH_6.6.1p1, OpenSSL 1.0.1e-fips 11 Feb 2013

可以看到openssh的版本是6.6.1,openssl版本是1.0.1

2、准备工作

gcc:https://pan.baidu.com/s/1RcnWouHwDaq-rkto6SYaBA  提取码:dwvf

zlib-1.2.13:http://www.zlib.net/fossils/zlib-1.2.13.tar.gz

openssl-1.1.1t.tar.gz:https://www.openssl.org/source/openssl-1.1.1t.tar.gz   

openssh-9.2p1.tar.gz:https://mirrors.sonic.net/pub/OpenBSD/OpenSSH/portable/openssh-9.2p1.tar.gz

依次安装gcc zlib openssl openssh

3、安装gcc

将网盘下载的gcc安装包全部上传到服务器上,切换到gcc目录下,执行命令

#执行命令,忽略其他依赖检查
rpm -Uvh *.rpm --nodeps --force

warning: cpp-4.8.5-28.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:mpfr-3.1.1-4.el7                 ################################# [ 10%]
   2:libmpc-1.0.1-3.el7               ################################# [ 20%]
   3:cpp-4.8.5-28.el7                 ################################# [ 30%]
   4:kernel-headers-3.10.0-862.el7    ################################# [ 40%]
   5:glibc-headers-2.17-222.el7       ################################# [ 50%]
   6:glibc-devel-2.17-222.el7         ################################# [ 60%]
   7:gcc-4.8.5-28.el7                 ################################# [ 70%]
   8:pcre-devel-8.32-17.el7           ################################# [ 80%]
Cleaning up / removing...
   9:glibc-devel-2.17-55.el6          ################################# [ 90%]
  10:glibc-headers-2.17-55.el6        ################################# [100%]

4、安装zlib

解压zlib-1.2.13.tar.gz,编译安装

[root@localhost ~]# tar zxvf zlib-1.2.13.tar.gz

[root@localhost ~]# cd zlib-1.2.13

[root@localhost zlib-1.2.13]# ./configure --prefix=/usr/local/zlib

[root@localhost zlib-1.2.13]# make && make install

5、安装openssl

[root@localhost ~]# tar zxvf openssl-1.1.1t.tar.gz

[root@localhost ~]# cd openssl-1.1.1t

[root@localhost openssl-1.1.1t]# ./config --prefix=/usr/local/ssl -d shared

[root@localhost openssl-1.1.1t]# make && make install

配置使用最新版本

ln -s /usr/local/ssl/bin/openssl /usr/bin/openssl

但是这里如果存在了,会报错
ln: failed to create symbolic link ‘/usr/bin/openssl’: File exists

所以我们使用覆盖命令
ln -sf /usr/local/ssl/bin/openssl /usr/bin/openssl


把新的库文件地址写入记录so库的配置文件中去
echo '/usr/local/ssl/lib' >> /etc/ld.so.conf


使配置生效并打印出来
ldconfig -v


查看版本
openssl version
OpenSSL 1.1.1t  7 Feb 2023 ##版本已更新为1.1.1


 6、安装openssh

#先卸载原openssh,卸载后切记不要断开ssh连接
[root@localhost ~]# yum remove openssh
#安装
[root@localhost ~]# tar zxvf openssh-9.2p1.tar.gz

[root@localhost ~]# cd openssh-9.2p1

[root@localhost openssh-9.2p1]# ./configure --prefix=/usr/local/openssh --with-zlib=/usr/local/zlib --with-ssl-dir=/usr/local/ssl

[root@localhost openssh-9.2p1]# make && make install

 此过程可能会出现一下错误

/usr/bin/ld: /usr/local/lib/libz.a(crc32.o): relocation R_X86_64_32 against `a local symbol' can not be used when making a shared object; recompile with -fPIC

解决方法如下:

cd  zlib-1.2.13  //进入zlib目录

CFLAGS="-O3 -fPIC" ./configure   //使用64位元的方法进行编译

make

make install

make clean

重新编译安装zilib之后再执行openssh的安装命令

7、配置openssh

#编辑sshd_config文件,在末尾追加三行数据
[root@localhost openssh-9.2p1]# vi /usr/local/openssh/etc/sshd_config
PermitRootLogin yes
PubkeyAuthentication yes
PasswordAuthentication yes

#按以下命令一步一步执行
[root@localhost openssh-9.2p1]# cd contrib/redhat/
[root@localhost redhat]# cp sshd.init  /etc/init.d/sshd
[root@localhost redhat]# chkconfig --add sshd
[root@localhost redhat]# cp /usr/local/openssh/etc/sshd_config /etc/ssh/sshd_config 
[root@localhost redhat]# cp /usr/local/openssh/sbin/sshd /usr/sbin/sshd
[root@localhost redhat]# cp /usr/local/openssh/bin/ssh /usr/bin/ssh
[root@localhost redhat]# cp /usr/local/openssh/bin/ssh-keygen /usr/bin/ssh-keygen
[root@localhost redhat]# cp /usr/local/openssh/etc/ssh_host_ecdsa_key.pub /etc/ssh/ssh_host_ecdsa_key.pub

#启动服务
[root@localhost redhat]# systemctl start sshd.service

#设置开机启动
[root@localhost redhat]# chkconfig --add sshd
[root@localhost redhat]# chkconfig sshd on

#查看版本
[root@localhost redhat]# ssh -V
OpenSSH_9.2p1, OpenSSL 1.1.1t  7 Feb 2023

升级完毕

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值