行业知识
centos7.9离线升级openssl和openssh9.2
2026-11-10 06:32:52
来源:互联网转载
1、查看本机ssh版本
ssh -VOpenSSH_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 --forcewarning: cpp-4.8.5-28.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEYPreparing... ################################# [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 versionOpenSSL 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位元的方法进行编译makemake installmake clean
重新编译安装zilib之后再执行openssh的安装命令
7、配置openssh
#编辑sshd_config文件,在末尾追加三行数据[root@localhost openssh-9.2p1]# vi /usr/local/openssh/etc/sshd_configPermitRootLogin yesPubkeyAuthentication yesPasswordAuthentication 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 -VOpenSSH_9.2p1, OpenSSL 1.1.1t 7 Feb 2023
升级完毕
下一篇:游戏怎么连国外服务器?