#参考网站 https://leheavengame.com/article/65a29edae7b7e20d2e1fbf7c
将openssl-1.1.1t.tar.gz openssh-9.4p1.tar.gz 和此脚本, 提前上传到服务器,
如果yum是内网源 ,进入 cd /etc/yum.repos.d/ 下,删除无关的源,入mysql,docker 等,(服务器可以连接公网可以无视这一步骤)
#!/bin/bash
yum remove openssh -y
rm -rf /etc/ssh/*
echo "=====================================删除旧ssh成功"
yum -y install zlib* pam-* gcc make
tar -zxvf openssl-1.1.1t.tar.gz
echo "============================================解压完成openssl"
cd openssl-1.1.1t
./config --prefix=/usr/local/openssl
make -j4 && make install
ln -sf /usr/local/openssl/bin/openssl /usr/bin/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
openssl version
echo `openssl version`
echo "=================升级ssl成功=========================="
cd ..
tar -zxvf openssh-9.4p1.tar.gz
cd openssh-9.4p1
yum -y install pam-devel
./configure --prefix=/usr/ --sysconfdir=/etc/ssh --with-openssl-includes=/usr/local/openssl/include --with-ssl-dir=/usr/local/openssl --with-zlib --with-md5-passwords --with-pam && make -j4&& make install
cp -a contrib/redhat/sshd.init /etc/init.d/sshd
chmod u+x /etc/init.d/sshd
sed -i '$a PasswordAuthentication yes' /etc/ssh/sshd_config
sed -i '$a PermitRootLogin yes' /etc/ssh/sshd_config
chkconfig --add sshd
chkconfig sshd on
service sshd restart
echo `ssh -V`