升级openssh
安装包地址:https://cdn.openbsd.org/pub/OpenBSD/OpenSSH/portable/
1.安装zlib
tar xf zlib-1.3.1.tar.gz
cd zlib-1.3.1
./configure --prefix=/usr/local/zlib
make && make install
2.升级openssl
tar xf openssl-3.0.0.tar.gz
cd openssl-3.0.0
./config --prefix=/usr/local/openssl shared zlib #一定要加上shared 参数,要不在安装openssh的时候就无法找到,最好指定安装路径,不然找不到安装好的openssl在哪
make && make install
#备份原来的openssl
mv /usr/bin/openssl /usr/bin/openssl.bak
mv /usr/include/openssl /usr/include/openssl.bak
#因为源码安装默认安装的位置是 /usr/local/ssl 需要将创建软链接到系统位置
ln -s /usr/local/ssl/bin/openssl /usr/bin/openssl
ln -s /usr/local/ssl/include/openssl /usr/include/openssl
#将openssl 的lib 库添加到系统
echo “/usr/local/ssl/lib” > /etc/ld.so.conf.d/openssl.conf
#使新添加的lib 被系统找到
ldconfig
#查看openssl版本
openssl version -a
3.升级openssh
#备份原openssh文件
mv /etc/init.d/ssh /etc/init.d/ssh.old
cp -r /etc/ssh /etc/ssh.old
#开始安装对应版本的openssh
tar xf openssh-8.7.tar.gz
cd openssh 8.7
./configure --prefix=/usr --sysconfdir=/etc/ssh --with-md5-passwords --with-pam --with-zlib --with-ssl-dir=/usr/local/ssl --with-privsep-path=/var/lib/sshd #需要指定openssl的安装路径
或者./configure --prefix=/usr --sysconfdir=/etc/ssh --with-zlib --with-md5-passwords --with-pam
make && make install
#可查看当前SSH的版本。
ssh -V
sshd -V
到目前所有升级就已经完成了
下面进行还原ssh配置
cd /etc/ssh
mv sshd_config sshd_config.default
cp …/ssh.old/sshd_config ./
#使用原来的/etc/init.d/ssh
mv /etc/init.d/ssh.old /etc/init.d/ssh
#取消注销指定服务
systemctl unmask ssh
#重启服务
systemctl restart sshd