- ssh -V
-
- OpenSSH_6.6.1p1, OpenSSL 1.0.1e-fips 11 Feb 2013
可以看到openssh的版本是6.6.1,openssl版本是1.0.1
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
将网盘下载的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%]
解压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
- [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
-
-
- #先卸载原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的安装命令
- #编辑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
升级完毕