Ubuntu的Ssh漏洞修复

官方网站下载最新版
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
  • 打开新窗口查看是否能正常连接
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值