1 前言

本文旨在介绍openssl以及openssh升级步骤,末文也介绍下升级过程中遇到的问题及处理方式(建议优先看末文)

2 环境准备

操作系统:CentOS Linux release 7.2.1511 (Core)
Linux version 3.10.0-327.el7.x86_64 (builder@kbuilder.dev.centos.org) (gcc version 4.8.3 20140911 (Red Hat 4.8.3-9) (GCC) ) #1 SMP Thu Nov 19 22:10:57 UTC 2015
源码包最新版官网查询获取:
https://www.openssl.org/source/openssl-1.1.1f.tar.gz
https://openbsd.hk/pub/OpenBSD/OpenSSH/portable/openssh-8.2p1.tar.gz

安装依赖包
[root@localhost ~]#yum install -y gcc openssl-devel pam-devel rpm-build
注:我环境中yum源直接是aliyun镜像未设置本地镜像;操作均通过secureCRT ssh连接至虚拟机

3 openssl升级

3.1 查看当前openssl版本号

[root@localhost ~]# openssl version -a
OpenSSL 1.0.2k-fips 26 Jan 2017
built on: reproducible build, date unspecified
platform: linux-x86_64
options: bn(64,64) md2(int) rc4(16x,int) des(idx,cisc,16,int) idea(int) blowfish(idx)
compiler: gcc -I. -I… -I…/include -fPIC -DOPENSSL_PIC -DZLIB -DOPENSSL_THREADS -D_REENTRANT -DDSO_DLFCN -DHAVE_DLFCN_H -DKRB5_MIT -m64 -DL_ENDIAN -Wall -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -Wa,–noexecstack -DPURIFY -DOPENSSL_IA32_SSE2 -DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_ASM_MONT5 -DOPENSSL_BN_ASM_GF2m -DRC4_ASM -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DMD5_ASM -DAES_ASM -DVPAES_ASM -DBSAES_ASM -DWHIRLPOOL_ASM -DGHASH_ASM -DECP_NISTZ256_ASM
OPENSSLDIR: “/etc/pki/tls”
engines: rdrand dynamic

3.2 获取源码包

[root@localhost ~]# wget https://www.openssl.org/source/openssl-1.1.1f.tar.gz

3.3 升级安装openssl

[root@localhost ~]# tar -zxvf openssl-1.1.1f.tar.gz
[root@localhost ~]# cd openssl-1.1.1f/
[root@localhost openssl-1.1.1f]# ./config --prefix=/usr/local/openssl --openssldir=/usr/local/openssl zlib shared
[root@localhost openssl-1.1.1f]# make
[root@localhost openssl-1.1.1f]# make install
#################################################
编译完成后配置
备份旧版openssl工具,链接新版openssl
[root@localhost openssl-1.1.1f]# mv /usr/bin/openssl /usr/bin/openssl.OFF
[root@localhost openssl-1.1.1f]# mv /usr/include/openssl /usr/include/openssl
[root@localhost openssl-1.1.1f]# ln -s /usr/local/openssl/include/openssl /usr/include/openssl
[root@localhost openssl-1.1.1f]# ln -s /usr/local/openssl/bin/openssl /usr/bin/openssl
配置库文件搜索路径
[root@localhost openssl-1.1.1f]# echo /usr/local/openssl/lib >> /etc/ld.so.conf
[root@localhost openssl-1.1.1f]# ldconfig
#################################################

3.4 查看版本确认

[root@localhost openssl-1.1.1f]# openssl version -a
OpenSSL 1.1.1f 31 Mar 2020
built on: Fri Apr 17 09:35:05 2020 UTC
platform: linux-x86_64
options: bn(64,64) rc4(16x,int) des(int) idea(int) blowfish(ptr)
compiler: gcc -fPIC -pthread -m64 -Wa,–noexecstack -Wall -O3 -DOPENSSL_USE_NODELETE -DL_ENDIAN -DOPENSSL_PIC -DOPENSSL_CPUID_OBJ -DOPENSSL_IA32_SSE2 -DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_ASM_MONT5 -DOPENSSL_BN_ASM_GF2m -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DKECCAK1600_ASM -DRC4_ASM -DMD5_ASM -DAESNI_ASM -DVPAES_ASM -DGHASH_ASM -DECP_NISTZ256_ASM -DX25519_ASM -DPOLY1305_ASM -DZLIB -DNDEBUG
OPENSSLDIR: “/usr/local/openssl”
ENGINESDIR: “/usr/local/openssl/lib/engines-1.1”
Seeding source: os-specific

4 升级openssh

4.1 查看当前版本

[root@localhost ~]# ssh -V
OpenSSH_6.6.1p1, OpenSSL 1.0.1e-fips 11 Feb 2013

4.2 下载源码包

[root@localhost ~]# wget https://openbsd.hk/pub/OpenBSD/OpenSSH/portable/openssh-8.2p1.tar.gz

4.3 升级openssh

###################################################
卸载原Openssh
[root@localhost ~]# mv /etc/ssh /etc/ssh.old
[root@localhost ~]# rpm -qa | grep openssh
openssh-clients-6.6.1p1-22.el7.x86_64
openssh-server-6.6.1p1-22.el7.x86_64
openssh-6.6.1p1-22.el7.x86_64
[root@localhost ~]# rpm -qa | grep openssh | xargs -i rpm -e --nodeps {}
warning: file /etc/ssh/ssh_config: remove failed: No such file or directory
warning: file /etc/ssh/sshd_config: remove failed: No such file or directory
warning: file /etc/ssh/moduli: remove failed: No such file or directory
warning: file /etc/ssh: remove failed: No such file or directory
[root@localhost ~]#
[root@localhost ~]# rpm -qa | grep openssh

解压并安装新版openssh安装包

[root@localhost ~]#tar -zxvf openssh-8.2p1.tar.gz
[root@localhost ~]# cd openssh-8.2p1/
[root@localhost openssh-8.2p1]# ./configure --prefix=/usr --sysconfdir=/etc/ssh --with-md5-passwords --with-pam --with-zlib --with-ssl-dir=/usr/local/openssl --without-hardening
执行后出现以下内容则可下一步编译

OpenSSH has been configured with the following options:User binaries: /usr/binSystem binaries: /usr/sbinConfiguration files: /etc/sshAskpass program: /usr/libexec/ssh-askpassManual pages: /usr/share/man/manXPID file: /var/runPrivilege separation chroot path: /var/emptysshd default user PATH: /usr/bin:/bin:/usr/sbin:/sbinManpage format: docPAM support: yes

[root@localhost openssh-8.2p1]# make
[root@localhost openssh-8.2p1]# make install
编译完成后,执行相关配置
[root@localhost openssh-8.2p1]# cp contrib/redhat/sshd.init /etc/init.d/sshd
[root@localhost openssh-8.2p1]# chkconfig --add sshd
[root@localhost openssh-8.2p1]# chkconfig --list | grep sshd

Note: This output shows SysV services only and does not include nativesystemd services. SysV configuration data might be overridden by nativesystemd configuration.If you want to list systemd services use 'systemctl list-unit-files'.To see services enabled on particular target use'systemctl list-dependencies [target]'.sshd              0:off   1:off   2:on    3:on    4:on    5:on    6:off

[root@localhost openssh-8.2p1]# echo “PermitRootLogin yes” >> /etc/ssh/sshd_config

[root@localhost openssh-8.2p1]# systemctl enable sshd
sshd.service is not a native service, redirecting to /sbin/chkconfig.
Executing /sbin/chkconfig sshd on
[root@localhost openssh-8.2p1]# systemctl restart sshd
[root@localhost openssh-8.2p1]# systemctl status sshd

● sshd.service - SYSV: OpenSSH server daemonLoaded: loaded (/etc/rc.d/init.d/sshd; bad; vendor preset: enabled)Active: active (running) since Fri 2020-04-17 15:50:45 CST; 7s agoDocs: man:systemd-sysv-generator(8)Process: 32951 ExecStart=/etc/rc.d/init.d/sshd start (code=exited, status=0/SUCCESS)Main PID: 32964 (sshd)CGroup: /system.slice/sshd.service└─32964 sshd: /usr/sbin/sshd [listener] 0 of 10-100 startupsApr 17 15:50:45 localhost.localdomain systemd[1]: Starting SYSV: OpenSSH serv...
Apr 17 15:50:45 localhost.localdomain sshd[32964]: Server listening on 0.0.0....
Apr 17 15:50:45 localhost.localdomain sshd[32964]: Server listening on :: por...
Apr 17 15:50:45 localhost.localdomain sshd[32951]: Starting sshd:[  OK  ]
Apr 17 15:50:45 localhost.localdomain systemd[1]: Started SYSV: OpenSSH serve...
Hint: Some lines were ellipsized, use -l to show in full.

4.4 查看版本确认

[root@localhost openssh-8.2p1]# netstat -tnl 查看端口监听情况
[root@localhost openssh-8.2p1]# ssh -V
OpenSSH_8.2p1, OpenSSL 1.1.1f 31 Mar 2020
则升级安装完成,可退出crt验证

5 遇到的问题

1、开始升级时想着卸载掉原有的版本,卸载后安装openssl依赖包时执行报错如下
[root@localhost ~]# yum install -y gcc openssl-devel pam-devel rpm-build
There was a problem importing one of the Python modules
required to run yum. The error leading to this problem was:

libssl.so.10: cannot open shared object file: No such file or directory

Please install a package which provides this module, or
verify that the module is installed correctly.

It’s possible that the above module doesn’t match the
current version of Python, which is:
2.7.5 (default, Nov 20 2015, 02:00:19)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-4)]

If you cannot solve this problem yourself, please go to
the yum faq at:
http://yum.baseurl.org/wiki/Faq
原因为:卸载openssl时将yum跟wget依赖的库libssl.so.10、 libcrypto.so.10(实际此两库是软连接的openssl的库)删掉,所以执行yum跟wget命令时会报以上错误
解决方案:百度链接https://blog.csdn.net/baidu_33864675/article/details/93332571
自己尝试过直接用旧版本openssl的libssl.so.1.0.2k以及libcrypto.so.1.0.2k放/usr/lib64然后做软连接即可恢复;
需要说明的是,此文档安装方式没有卸载旧的openssl所以按照此文档方式不会出现此问题;(看网上说法大概意思由于依赖的原有的openssl库有很多,不建议卸载掉原有系统自带的openssl)
2、执行openssl version查看openssl版本时,报如下错误
[root@localhost openssl]# openssl version
openssl: error while loading shared libraries: libcrypto.so.1.1: cannot open shared object file: No such file or directory
原因:openssl库位置不对
解决方案:创建响应的软连接
ln -s /usr/local/openssl/lib/libssl.so.1.1 /usr/lib64/libssl.so.1.1
ln -s /usr/local/openssl/lib/libcrypto.so.1.1 /usr/lib64/libcrypto.so.1.1

3、安装完openssl1.1.1f之后,执行yum命令会报如下错误

[root@localhost openssl-1.1.1f]# yum install openssl-devel
There was a problem importing one of the Python modules
required to run yum. The error leading to this problem was:/lib64/libcrypto.so.10: version `libcrypto.so.10' not found (required by /usr/lib64/python2.7/lib-dynload/_hashlib.so)Please install a package which provides this module, or
verify that the module is installed correctly.It's possible that the above module doesn't match the
current version of Python, which is:
2.7.5 (default, Nov 20 2015, 02:00:19)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-4)]If you cannot solve this problem yourself, please go to
the yum faq at:http://yum.baseurl.org/wiki/Faq

原因:即使创建了此版本对应的库给libcrypto.so.10做符号链接,仍然不能解决问题,猜测可能是当前系统yum/wget依赖的openssl库版本太高。
解决方法:复制了低版本的openssl库版本,libssl.so.1.0.2k以及libcrypto.so.1.0.2k版本至/usr/lib64目录,然后创建libssl.so.10以及libcrypto.so.10符号链接;运行yum跟wget可正常响应;暂不清楚这样处理是否对新升级的openssl有啥影响

4、升级安装完ssh后,执行ssh -V查看版本openssh是最新版本,但看openssl版本仍是旧版本

[root@localhost openssh-8.2p1]# ssh -V
OpenSSH_8.2p1, OpenSSL 1.0.2k-fips  26 Jan 2017

原因为编译安装openssh的时候,指向的ssl不是新版本,需要–with-ssl-dir的时候指定对应版本的路径(即得与编译安装openssl时–openssldir路径一致)
5、升级openssh时编译报错“OpenSSL library not found”
卸载openssl-devel然后再yum install openssl-devel没出现此报错,具体原因未知
6、升级openssh时编译报错“configure: error: PAM headers not found”
缺少pam-devel包,安装pam-devel包即可
7、升级完openssl即openssh退出crt远程登陆后,出现再以root登陆虚拟机出现即使密码输入对了,仍提示密码输入错误问题
解决:网上搜寻了如下比较全

7.1 openssh升级后,终端登陆会提示:WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!
应该在终端的~/.ssh/known_hostswe文件中将服务器ip对应的公钥信息删除再尝试登陆。
7.2 解决WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED仍然无法登陆,将/etc/ssh中的文件全部设置权限600 ,重启sshd服务,再在终端尝试登陆。
7.3 还是无法登陆的话,考虑是否是/etc/ssh/sshd_config配置不对,常见的修改配置有:PermitRootLogin yes、PubkeyAuthentication yes、PasswordAuthentication yes。
7.4 最重要的还是查看sshd服务的状态:service sshd status/sysctemctl status sshd。
7.5 如果sshd服务状态提示:get shadow information for root。考虑是否是selinux启用了策略,将/etc/selinux/config 文件中的SELINUX=enforcing 修改为 SELINUX=disabled。

亲测,以上在centos6也能正常部署(差别在于启动服务使用service),安装之前可先安装依赖包“yum install -y gcc openssl-devel pam-devel rpm-build”
另远程CRT登陆操作升级,一定记得重启sshd服务之前,关闭selinux;以及配置允许root登陆(PermitRootLogin yes)

openssl以及openssh升级相关推荐

  1. 一键脚本升级OpenSSL、OpenSSH

    OpenSSL.OpenSSH一般官方每年会更新两次,修复已知安全漏洞和各种程序Bug.随着越来越多的企业对安全意识的提高,一般每年也会内部开展两次安全整改检查工作,其中OpenSSL.OpenSSH ...

  2. Centos7.6编译升级openssl、openssh服务,关闭rpcbind服务

    目录 1. 安装telnet服务(可选) 2. openssl升级 2.1 备份原有openssl服务 2.2编译安装.及编译安装出现的报错 2.3 建立软连接 2.4 更新动态连接数据库 2.5查看 ...

  3. openssh-浅谈openssl和openssh的升级

    最近项目上有服务器漏洞被扫描出来,是关于openssl的 之前没怎么关注过这个问题,于是着手去了解了以下 发现有些坑,分享下自己的经验. 中间过程比较长,想省事的直接跳到第四节,解决漏洞观看 一.   ...

  4. linux升级ssh到6.6版本,CentOS6.5 openssh升级到openssh-7.6版本

    CentOS6.5 openssh升级到openssh-7.6版本 2018-8-3 foooy 升级前保证故障后能现场处理,或者远程卡处理,否则不要这样直接升级 yum install -y gcc ...

  5. linux openssh升级8.1,Centos7利用rpm升级OpenSSH到openssh-8.1p1版本

    由于近期安全事故频发,打算把机器OpenSSH升级到最新版本,找了一圈,发现分享的rpm包就到7.4版本,最新版已经到8.1.p1,所以博客自编译一个openssh-8.1p1的rpm包进行分享. 检 ...

  6. linux openssh升级7.4,RHEL Centos上升级OpenSSH7.4p1

    二.配置yum源 1.新建光盘挂载目录/yum mkdir /yum 2.上传光盘到机器的某个目录,然后挂载到/yum目录下 mount -o loop rhel-server-6.5-x86_64- ...

  7. centos 6.7 openssh 升级到openssh 7.1p

    openssh 升级主要解决: OpenSSH(OpenBSD Secure Shell)是OpenBSD计划组所维护的一套用于安全访问远程计算机的连接工具.该工具是SSH协议的开源实现,支持对所有的 ...

  8. OPENSSH升级为7.4

    导语 Redhat企业级系统的6.7版自带SSH版本为OpenSSH_5.3p1, 基于审计和安全性需求,建议将其升级到最新的OpenSSH版本,当前官网最新版本为7.4p1. 本文档将详细介绍Ope ...

  9. linux openssh 升级最新版本

    直接上脚本吧! 前提条件: 1.准备好本地yum源,防止突发情况无法回退 2.注意对应系统版本,此版本为centos7系列 #!/bin/bash###升级penssl部分### yum -y ins ...

最新文章

  1. arm32 linux 内存分布,gcc代码反汇编查看内存分布[2]: arm-linux-gcc
  2. python 玩公众号游戏_Python入门太难?不如从玩塔防小游戏开始,玩通关就能学会编程...
  3. (63)0环与3环通信非常规方式 —— 0环InlineHook
  4. VTLN(Vocal Tract Length Normalisation)
  5. 1005:I Think I Need a Houseboat-poj
  6. 以太坊2.0存款合约地址余额28.87万ETH,进度达55%
  7. 设计模式—23种设计模式总览
  8. POJ 3668 枚举?
  9. 代码文件夹带有红色感叹号_接口测试平台代码实现7:菜单的开发
  10. SEO_关键词研究工具
  11. 《游牧者的抉择》读书笔记
  12. mt6573 环境配置
  13. mistake - pwnable
  14. 高中数学学习技巧,这几步你都做到了吗?
  15. 10.3_word2vec-pytorch
  16. 神经系统位置图高清,中枢神经系统位置图
  17. 刘氏广传公家族七公子巨波公后裔V0.2
  18. 计算机操作系统(八)——并发程序设计
  19. 智能客服能用于哪些场景?
  20. 暑期学习与“懒人电商”项目经验总结

热门文章

  1. 【榜首团队专访】冲刺复赛,他们有绝招
  2. 深度学习基础 | RNN家族全面解析
  3. mysql树形结构的效率_MySQL存储树形数据优化技笔记
  4. Leetcode每日一题:189.rotate-array(旋转数组)
  5. Leetcode每日一题:121.best-time-to-buy-and-sell-stock(买股票的最佳时机)
  6. Algorithm:贪心策略之区间选点问题
  7. Leetcode:5.longest-palindromic-substring(最长回文子串)
  8. TensorFlow2.0:自定义层与自定义网络
  9. 时隔25年重访 Linus:流量时代的“技术大师”
  10. 基于ConvLSTM的伦敦空气质量预测(1) 数据处理