官方网站下载最新版
http://www.zlib.net/
https://www.openssl.org/source/
http://ftp.openbsd.org/pub/OpenBSD/OpenSSH/portable/
1. 安装zlib
- 解压
tar -zxvf zlib-1.3.1.tar.gz
- 进入目录
cd zlib-1.3.1
- 检测系统环境
./configure --prefix=/usr/local/zlib
- 编译安装
make && make install
- 加载配置
echo '/usr/local/zlib/lib' >> /etc/ld.so.conf
ldconfig -v
2. 升级openssl
- 解压
cd ..
tar -zxvf openssl-1.1.1w.tar.gz
- 进入目录
cd openssl-1.1.1w
- 备份
mv /usr/bin/openssl /usr/bin/openssl.bak
- 检测系统环境
./config
- 编译安装(等待运行完成,千万别退出)
make && make install
- 加载配置
ln -s /usr/local/bin/openssl /usr/bin/openssl
ldconfig -v
- 检查是否更新成功
openssl version
3. 升级openSSH(谨慎)
- 解压
cd ..
tar -zxvf openssh-9.7p1.tar.gz
- 进入目录
cd openssh-9.7p1
- 再打开一个窗口,防止更新时离线
- 修改ssh配置文件
vim /etc/ssh/sshd_config
输入i进入输入模式
修改为或在最后一行添加
PermitRootLogin yes
按esc退回至命令行模式
输入:wq保存并退出
- 重启ssh,检查是否正常(无输出即为正常)
systemctl restart sshd
- 备份启动脚本以及配置文件
cp /etc/init.d/ssh /etc/init.d/ssh.old
cp -r /etc/ssh /etc/ssh.old
- 检测系统环境
./configure --prefix=/usr --sysconfdir=/etc/ssh --with-md5-passwords --with-pam --with-zlib --with-ssl=/usr/local/bin/openssl --with-privsep-path=/var/lib/sshd
- 编译安装(等待运行完成,千万别退出)
make && make install
- 重启ssh
mv /etc/ssh/ssh_config /etc/ssh/ssh_config_bak
mv /etc/ssh/sshd_config /etc/ssh/sshd_config_bak
mv /etc/ssh/moduli /etc/ssh/moduli_bak
make install
echo 'PermitRootLogin yes' >>/etc/ssh/sshd_config
echo 'PubkeyAuthentication yes' >>/etc/ssh/sshd_config
echo 'PasswordAuthentication yes' >>/etc/ssh/sshd_config
chmod 754 /var/run/sshd/
rm -f /lib/systemd/system/ssh.service
systemctl unmask ssh
systemctl enable sshd
systemctl restart sshd.service
systemctl status sshd.service
- 检查是否更新成功
sshd -V
- 打开新窗口查看是否能正常连接