centos7升级openssl
升级了openssh,顺带着openssl也一并升级了
先打开https://openssl-library.org/source/index.html
下载最新的openssl,并且上传服务器,这里我下载的版本是openssl-3.3.2
执行命令解压缩
tar xzf openssl-3.3.2.tar.gz
cd openssl-3.3.2/
这里先安装依赖模块
sudo yum install perl-IPC-Cmd perl-Data-Dumper gcc gcc-c++ perl perl-devel -y
开始编译
./config enable-tls1_3 --prefix=/usr/local/openssl-3.3.2 --libdir=lib
提示成功,继续执行
make && make install
这个时候经常出现报错
/usr/bin/perl util/mkinstallvars.pl PREFIX=. BINDIR=apps APPLINKDIR=ms LIBDIR= INCLUDEDIR=include “INCLUDEDIR=./include” ENGINESDIR=engines MODULESDIR=providers “VERSION=3.3.2” “LDLIBS=-lz -ldl -pthread ” > builddata.pm
“pairs” is not exported by the List::Util module
Can’t continue after import errors at util/mkinstallvars.pl line 14.
BEGIN failed–compilation aborted at util/mkinstallvars.pl line 14.
提示是 List::Util 模块有问题
修复他
yum install cpan -y
sudo cpan List::Util
结果还是报错
/usr/bin/perl “-I.” “-Mconfigdata” “-Mbuilddata” “util/dofile.pl” “-oMakefile” exporters/cmake/OpenSSLConfig.cmake.in > OpenSSLConfig.cmake
builddata.pm did not return a true value.
BEGIN failed–compilation aborted.
make: *** [OpenSSLConfig.cmake] 错误 255
看样子是配置的问题
make clean
sudo cpan IPC::Cmd
sudo cpan Exporter
./config enable-tls1_3 --prefix=/usr/local/openssl-3.3.2 --libdir=lib
make
sudo make install
重新做链接
ln -sf /usr/local/openssl-3.3.2/bin/openssl /usr/bin/openssl
ln -s /usr/local/openssl-3.3.2/include/openssl /usr/include/openssl
检查是否有依赖缺失
ldd /usr/bin/openssl
如果显示有not found,说明需要手动做链接
例如提示
libssl.so.3 => not found
sudo ln -sf /usr/local/openssl-3.3.2/lib/libssl.so.3 /usr/lib64/libssl.so.3
sudo ln -sf /usr/local/openssl-3.3.2/lib/libcrypto.so.3 /usr/lib64/libcrypto.so.3
更新动态链接器缓存
sudo ldconfig
openssl version
完成!
——————————————————————————————————————————————
联动上篇openssh升级,如果不采用rpm安装的,可以编译升级openssh
./configure --prefix=/usr --sysconfdir=/etc/ssh --with-ssl-dir=/usr/local/openssl-3.3.2 --with-zlib --with-pam
make && make install
chmod 600 /etc/ssh/*
systemctl restart sshd
其他问题记录:
执行ssh-V 依旧是原版本,说明ssh文件未覆盖安装,可以在make install之前,mv或者rm /usr/sbin/sshd、/usr/bin/ssh、/usr/bin/ssh-keygen,如果安装在其他目录的,可以cp文件过去
cp /home/openssh-9.9p1/contrib/redhat/sshd.init /etc/init.d/sshd
cp /usr/local/openssh/sbin/sshd /usr/sbin/sshd
cp /usr/local/openssh/bin/ssh /usr/bin/ssh
cp /usr/local/openssh/bin/ssh-keygen /usr/bin/ssh-keygen
安装后无法连接,可以检查selinux是否关闭,执行setforce 0 如果可以连接了,那说明selinux未关闭,永久关闭可以修改/etc/selinux/config,将SELINUX设置为disabled