环境介绍:
首先模拟环境为vmware下CentOS7,镜像方面为7.4的minimal版本也就是无任何附加软件。由于openssl是一个非常基础的软件所以会有众多软件依赖于openssl,安装升级一个新版本的openssl会导致覆盖掉原操作系统的openssl,这会导致曾经依赖于openssl的软件功能变得不可用。
具体流程:

查看操作系统版本:

[root@localhost ~]# cat /etc/redhat-release

python 查openssl版本 怎么查看openssh版本_python 查openssl版本


查看openssh版本:

[root@localhost ~]# ssh -V

python 查openssl版本 怎么查看openssh版本_python 查openssl版本_02


查看openssl版本:

python 查openssl版本 怎么查看openssh版本_配置文件_03


一:安装telnet服务:

检查服务器上是否存在telnet:

[root@localhost openssh-7.9p1]# rpm -qa | grep telnet

python 查openssl版本 怎么查看openssh版本_python 查openssl版本_04


若未安装,则安装telnet,否则忽略此步骤

[root@localhost ~]# yum install telnet telnet-servertelnet 是挂在 xinetd 底下的,所以同时查看是否安装了xinetd服务

[root@localhost ~]rpm -qa | grep xinetd

python 查openssl版本 怎么查看openssh版本_python 查openssl版本_05


如果没有则安装:

[root@service1 ssh]# yum -y install xinetd二.配置telnet,设置开机启动:

[root@localhost ~]# chkconfig --list | grep telnet

python 查openssl版本 怎么查看openssh版本_python 查openssl版本_06


ekrb5-telnet: off

krb5-telnet: on

[root@localhost ~]# chkconfig krb5-telnet on

python 查openssl版本 怎么查看openssh版本_库文件_07


修改配置文件

vi /etc/xinetd.d/krb5-telnet

将”disable= yes”改成” disable=no”

python 查openssl版本 怎么查看openssh版本_库文件_08


在centos6系统上修改配置文件后重新执行

python 查openssl版本 怎么查看openssh版本_bc_09


会报这个错误,因为telnet服务是默认不托管于xinetd的,telnet是非独立服务,service telnet start 服务起不来,xinetd又不能唤醒该服务。telnet就不能开启服务。

需要对xinetd服务进行重启,此时telnet服务会启动。

将xinetd服务设置为开机自启动:
[root@localhost ~]# chkconfig xinetd on

查看telnet端口状态:

[root@localhost ~]#netstat -tnl |grep 23

tcp 0 0 0.0.0.0:23 0.0.0.0:* LISTEN

python 查openssl版本 怎么查看openssh版本_bc_10

连接测试:

telnet ip

python 查openssl版本 怎么查看openssh版本_python 查openssl版本_11

三:

下载想要升级的ssl版本openssl-1.0.2h

[root@service1~]#wget -c http://artfiles.org/openssl.org/source/old/1.0.2/openssl-1.0.2h.tar.gz

[root@localhost ~]# tar xf openssl-1.0.2h.tar.gz

[root@localhost ~]# cd openssl-1.0.2h

[root@localhost ~]#./config --prefix=/usr/local/ssl --openssldir=/etc/ssl

--libdir=lib shared fPIC zlib-dynamic enable-camellia

[root@localhost ~]#make depend

[root@localhost ~]#make && make install

[root@localhost ~]#make MANDIR=/usr/share/man MANSUFFIX=ssl install &&

[root@localhost ~]#install -dv -m755 /usr/share/doc/openssl-1.0.2h &&

[root@localhost ~]#cp -vfr doc/* /usr/share/doc/openssl-1.0.2h

python 查openssl版本 怎么查看openssh版本_bc_12

额外配置必须(为Openssh升级做准备)做好备份

[root@localhost ~]#mv /usr/bin/openssl /usr/bin/openssl.bak

[root@localhost ~]#ln -s /usr/local/ssl/bin/openssl /usr/bin/openssl

[root@localhost ~]#ln -s /usr/local/ssl/include/openssl /usr/include/openssl

[root@localhost ~]#echo "/usr/local/ssl/lib" >> /etc/ld.so.conf

[root@localhost ~]#ldconfig -v

python 查openssl版本 怎么查看openssh版本_bc_13


openssl升级成功

[root@localhost ~]#openssl version -a

python 查openssl版本 怎么查看openssh版本_配置文件_14


Openssh升级:

将原openssh打包备份:

[root@service1 ssh]# tar zcvf /root/ssh.tar.gz /etc/ssh/

python 查openssl版本 怎么查看openssh版本_库文件_15


-安装相应的依赖包

configure: error: * zlib.h missing - please install first or check config.log
如遇该错误,请安装
[root@service1 openssh-7.9p1]# yum -y install zlib

[root@service1 openssh-7.9p1]# rpm -qa | grep zlib

zlib-static-1.2.3-29.el6.x86_64

zlib-devel-1.2.3-29.el6.x86_64

zlib-1.2.3-29.el6.x86_64configure: error: PAM headers not found

如遇该错误,请安装

[root@service1 openssh-7.9p1]#yum -y install pam-devel

下载openssh 7.9版本源码包:

[root@service1 ~]# tar xf openssh-7.9p1.tar.gz

[root@service1 ~]# cd openssh-7.9p1

[root@service1 ~]#./configure --prefix=/usr --sysconfdir=/etc/ssh --with-zlib --with-md5-passwords --with-ssl-dir=/usr/local/ssl --without-hardening

python 查openssl版本 怎么查看openssh版本_库文件_16


可选项:--with-pam --with-tcp-wrappers

编译成功:

python 查openssl版本 怎么查看openssh版本_库文件_17

如果编译成功:

[root@service1 ~]#make && make install

python 查openssl版本 怎么查看openssh版本_库文件_18

直接用root登录终端(此处根据自身情况考虑)

echo "PermitRootLogin yes" >> /etc/ssh/sshd_config

echo 'X11Forwarding yes' >> /etc/ssh/sshd_config

echo "PasswordAuthentication yes" >> /etc/ssh/sshd_config

拷贝启动脚本.

[root@service1 ~]mv /usr/sbin/sshd /usr/sbin/sshd.OFF

[root@service1 ~]ln -s /root/openssh-7.9p1/sshd /usr/sbin/sshd

python 查openssl版本 怎么查看openssh版本_库文件_19


将原版本ssl卸载:

[root@service2 openssh-7.9p1]# rpm -qa | grep openssl

openssl-1.0.1e-48.el6.x86_64

[root@service2 ~]# rpm -e openssl-1.0.1e-48.el6.x86_64

禁止卸载,显示依赖关系。

python 查openssl版本 怎么查看openssh版本_配置文件_20


记录这两个库文件并将其备份。

libcrypto.so.10

libssl.so.10

cp /usr/lib64/libcrypto.so.10 /usr/lib64/libcrypto.so.10.old

cp /usr/lib64/libssl.so.10 /usr/lib64/libssl.so.10.old

强制卸载:

[root@service2 ~]#rpm -qa | grep openssl | xargs rpm -e --nodeps将两个库文件做软链接:

[root@service2 ~]#ln -s /root/openssl-1.0.2h/libssl.so.1.0.0 /usr/lib64/libssl.so.10

[root@service2 ~]# ln -s /root/openssl-1.0.2h/libcrypto.so.1.0.0 /usr/lib64/libcrypto.so.10

由于之前备份时并没有将原来的文件删除需要手动删除

python 查openssl版本 怎么查看openssh版本_python 查openssl版本_21

[root@service2 ~]# /etc/init.d/sshd  restart 
Stopping sshd:                                             [  OK  ] 
Starting sshd:                                             [  OK  ]
/etc/ssh/sshd_config line 81: Unsupported option GSSAPIAuthentication 

/etc/ssh/sshd_config line 83: Unsupported option GSSAPICleanupCredentials 

/etc/ssh/sshd_config line 97: Unsupported option UsePAM[root@service2 ~]# vim /etc/ssh/sshd_config 

注释掉 81,83,97 三行 

[root@service2 ~]#echo "PermitRootLogin yes" >> /etc/ssh/sshd_config 

[root@service2 ~]#echo 'X11Forwarding yes' >> /etc/ssh/sshd_config 

[root@service2 ~]#echo "PasswordAuthentication yes" >> /etc/ssh/sshd_config 

[root@service2 ~]# /etc/init.d/sshd  restart

升级成功。
导致依赖旧库安装的软件无法正常使用待解决。。。