一、准备工作: 一)主机版本情况如下: 1、主机环境:

root@xuhs:/root>cat /etc/redhat-release `
CentOS Linux release 7.8.2003 (Core)

2、OpenSSH以及OpenSSL版本:

root@xuhs:/root>ssh -V`
OpenSSH_8.5p1, OpenSSL 1.0.2k-fips  26 Jan 2017

二)rmp包准备如下: 1、准备好OpenSSH_8.6p1安装包(目前为最新): openssh-8.6p1.tar.gz 下载地址如下:https://openbsd.hk/pub/OpenBSD/OpenSSH/portable/

2、准备好telnet应用相关rmp包;

root@xuhs:/home/xuhs>ls -ltr
-rw-r----- 1 xuhs   131484 Apr  4  2020 xinetd-2.3.15-14.el7.x86_64.rpm
-rw-r----- 1 xuhs    41996 Apr  8  2020 telnet-server-0.17-65.el7_8.x86_64.rpm
-rw-r----- 1 xuhs    59380 Sep 25  2020 telnet-0.17-48.el6.x86_64.rpm

3、准备好OpenSSL安装包: openssl-1.1.1k.tar.gz 下载地址:https://www.openssl.org/source/openssl-1.1.1k.tar.gz

三)升级过程: (一)安装配置telnet服务: 1、创建账号:

root@xuhs:/root>useradd -g users -d /home/xuhs  xuhs
root@xuhs:/root>echo '1qaz@WSX' | passwd --stdin xuhs
root@xuhs:/root>chage -M 99999 xuhs

3、上传文件包packages.zip,文件包主要是telnet服务包: 以普通账户登录,这里使用xuhs,然后使用rz -e 上传所有包。

4、解压缩,安装并配置telnet服务:

root@xuhs:/home/xuhs>unzip packages.zip
root@xuhs:/home/xuhs>rpm -ivh /home/xuhs/packages/telnet-0.17-48.el6.x86_64.rpm 
root@xuhs:/home/xuhs>rpm -ivh /home/xuhs/packages/telnet-server-0.17-65.el7_8.x86_64.rpm
root@xuhs:/home/xuhs>rpm -ivh /home/xuhs/packages/xinetd-2.3.15-14.el7.x86_64.rpm

5、增加telnet登录虚拟终端并启动telnet服务:

root@xuhs:/home/xuhs>echo -e 'pts/0\npts/1\npts/2\npts/3\npts/4\npts/5' >> /etc/securetty
root@xuhs:/home/xuhs>systemctl start telnet.socket xinetd

6、保证可以使用telnet远程登录主机:

root@xuhs:/home/xuhs>telnet 192.168.100.207
Trying 192.168.100.207...
Connected to 192.168.100.207.
xuhs login: xuhs
Password: 

(二)升级OpenSSL: 1、备份:

root@xuhs:/home/xuhs>mv /usr/bin/openssl /usr/bin/openssl.bak
root@xuhs:/home/xuhs>mv /usr/include/openssl /usr/include/openssl.bak

2、cd到usr/local/并解压openssl:

root@xuhs:/home/xuhs>cd /usr/local/
root@xuhs:/usr/local>tar -zxvf openssl-1.1.1k.tar.gz

3、进入openssl-1.1.1k目录并编译

root@xuhs:/usr/local>cd /usr/local/openssl-1.1.1k
root@xuhs:/usr/local/openssl-1.1.1k>./config --prefix=/usr/local/openssl
root@xuhs:/usr/local/openssl-1.1.1k>make && make install

4、备份并建立链接:

root@xuhs:/usr/local/openssl-1.1.1k>ln -s /usr/local/openssl/bin/openssl /usr/bin/openssl
root@xuhs:/usr/local/openssl-1.1.1k>ln -s /usr/local/openssl/include/openssl /usr/include/openssl

5、查看并搜索动态链接库:

echo "/usr/local/openssl/lib" >> /etc/ld.so.conf
ldconfig -v

6、查看是否升级成功 openssl version

(三)升级OpenSSH到OpenSSH_8.6p1: 1、停止ssh服务,并做好备份:

root@xuhs:/home/xuhs/xuhs>systemctl stop sshd
root@xuhs:/home/xuhs/xuhs>mv /etc/ssh/ /etc/ssh.bak
root@xuhs:/home/xuhs/xuhs>mv /etc/pam.d/sshd  /etc/pam.d/sshd.bak

2、删除的openssh:

root@xuhs:/home/xuhs/xuhs>yum remove -y $(rpm -qa | grep openssh)
Loaded plugins: fastestmirror, langpacks
Error: Need to pass a list of pkgs to remove
 Mini usage:
erase PACKAGE...
Remove a package or packages from your system
aliases: remove, autoremove, erase-n, erase-na, erase-nevra, autoremove-n, autoremove-na, autoremove-nevra, remove-n, remove-na, remove-nevra

3、解压缩并进行编译:

root@xuhs:/home/xuhs/xuhs>tar xvf /home/xuhs/xuhs/openssh-8.6p1.tar.gz -C /home/xuhs/
openssh-8.6p1/sshd_config.0
openssh-8.6p1/ssh_config.0
openssh-8.6p1/aclocal.m4
openssh-8.6p1/configure
openssh-8.6p1/config.h.in
root@xuhs:/home/xuhs/xuhs>cd /home/xuhs/openssh-8.6p1/
root@xuhs:/home/xuhs/openssh-8.6p1>./configure --prefix=/usr --sysconfdir=/etc/ssh --with-md5-passwords --with-ssl-dir=/usr/local/openssl --with-pam

checking for cc... cc
.......
PAM is enabled. You may need to install a PAM control file 
for sshd, otherwise password authentication may fail. 
Example PAM control files can be found in the contrib/ 
subdirectory

root@xuhs:/home/xuhs/openssh-8.6p1>make && make install
conffile=`echo sshd_config.out | sed 's/.out$//'`; \
............
/bin/mkdir -p /etc/ssh
ssh-keygen: generating new host keys: RSA DSA ECDSA ED25519 
/usr/sbin/sshd -t -f /etc/ssh/sshd_config

4、更新sshd.init文件:

root@xuhs:/home/xuhs/openssh-8.6p1>cp -a /home/xuhs/openssh-8.6p1/contrib/redhat/sshd.init /etc/init.d/sshd
cp: overwrite ‘/etc/init.d/sshd’? y
root@xuhs:/home/xuhs/openssh-8.6p1>mv /etc/pam.d/sshd.bak /etc/pam.d/sshd
root@xuhs:/home/xuhs/openssh-8.6p1>mv /etc/ssh /etc/ssh1.bak
root@xuhs:/home/xuhs/openssh-8.6p1>mv /etc/ssh.bak /etc/ssh

5、启动服务:

root@xuhs:/home/xuhs/openssh-8.6p1>chmod 600 /etc/ssh/*key
root@xuhs:/home/xuhs/openssh-8.6p1>service sshd start
Starting sshd (via systemctl):  Warning: sshd.service changed on disk. Run 'systemctl daemon-reload' to reload units.
                                                           [  OK  ]
root@xuhs:/home/xuhs/openssh-8.6p1>systemctl enable sshd
sshd.service is not a native service, redirecting to /sbin/chkconfig.
Executing /sbin/chkconfig sshd on
root@xuhs:/home/xuhs/openssh-8.6p1>/sbin/chkconfig sshd on

6、查看ssh服务是否运行正常,OpenSSH、OpenSSL是否升级完成:

xuhs@xuhs:/home/gealarm>ssh -V
OpenSSH_8.6p1, OpenSSL 1.1.1k  25 Mar 202

7、测试:

xuhs@xuhs:/home/xuhs>ssh 192.168.100.207
xuhs@192.168.100.207's password: 

输入密码后登录正常即可。

四、遇到的问题总结: 一)问题一: 1、执行编译有以下报错:

./configure --prefix=/usr --sysconfdir=/etc/ssh --with-md5-passwords --with-ssl-dir=/usr/local/ssl --with-pam

checking OpenSSL library version... not found
configure: error: OpenSSL library not found

2、问题分析:checking OpenSSL library没有找到,OpenSSL安装路径为/usr/local/ssl,使用configure没有检测到OpenSSL的lib,故报错。

3、解决方法: 修改OpenSSL安装路径为/usr/local/openssl后重新执行configure即可: ./configure --prefix=/usr --sysconfdir=/etc/ssh --with-md5-passwords --with-ssl-dir=/usr/local/openssl --with-pam

二)问题二: 1、问题描述:非root下无法正常使用ssh远程其他主机(root下正常),现象如下: ssh: error while loading shared libraries: libcrypto.so.1.1: cannot open shared object file: No such file or directory

2、问题分析: (1)查看libcrypto.so.1.1正常存在; (2)ssh升级后运行正常; (3)非root下调用libcrypto.so.1.1失败,但是root可以正常使用,可判断权限出现问题。

3、解决办法(给所有权限吧):

root@xuhs:/root>cd /usr/local
root@xuhs:/root>chmod 777 openssl -R