1.升级openssl 1.0.2k到openssl-1.1.1w
mkdir /software
2.下载安装包
wget --no-check-certificate https://www.openssl.org/source/old/1.1.1/openssl-1.1.1w.tar.gz
3.编译并安装
3.1 安装zlib
yum install -y gcc gcc-c++ glibc make automake autoconf zlib zlib-devel
3.2解压openssl并安装
tar -zxf openssl-1.1.1w.tar.gz
cd openssl-1.1.1w/
./config shared zlib -fPIC --prefix=/usr/local/openssl
make -j 4
make install
3.3建立软链接
mv /usr/bin/openssl /usr/bin/openssl.bak
mv /usr/include/openssl /usr/include/openssl.bak
ln -s /usr/local/openssl/bin/openssl /usr/bin/openssl
ln -s /usr/local/openssl/include/openssl /usr/include/openssl
echo '/usr/local/openssl/lib' > /etc/ld.so.conf.d/openssl-x86_64.conf
ldconfig -v
openssl version -a
4.安装openssn7.4到9.6
4.1下载并安装
cd /software wget --no-check-certificate https://cdn.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-9.6p1.tar.gz
systemctl stop sshd
mv /etc/ssh /etc/ssh.bak
mv /usr/sbin/sshd /usr/sbin/sshd.bak
mv /usr/bin/ssh /usr/bin/ssh.bak
4.2卸载原ssh
rpm -qa | grep openssh rpm -e openssh-clients-7.5p1-1.x86_64 --nodeps
rpm -e openssh-server-7.5p1-1.x86_64
rpm -e openssh-7.5p1-1.x86_64
rpm -e openssh-debuginfo-7.5p1-1.x86_64 (可以试试yum卸载,yum remove openssh)
rpm -qa | grep openssh
4.3编译安装
tar -zxf openssh-9.6p1.tar.gz
cd openssh-9.6p1/
./configure --prefix=/usr/local/openssh --with-ssl-dir=/usr/local/openssl --with-zlib
make -j 4
make install
# 取消原有sshd启动方式并配置新版
sshd.service ls /usr/lib/systemd/system/ssh*
rm -f /usr/lib/systemd/system/ssh*
cp contrib/redhat/sshd.init /etc/init.d/sshd
# 复制sshd相关文件到新目录
mkdir /etc/ssh vim /usr/local/openssh/etc/sshd_config
PermitRootLogin yes
PubkeyAuthentication yes
cp /usr/local/openssh/etc/sshd_config /etc/ssh/sshd_config
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
cp /usr/local/openssh/etc/ssh_host_ecdsa_key.pub /etc/ssh/ssh_host_ecdsa_key.pub
# 启动sshd服务并设置开机启动
systemctl daemon-reload
systemctl start sshd && systemctl enable sshd
ssh -V
参考:https://www.cnblogs.com/williamzheng/p/18057229