1 前言
服务器系统龙笑天用 CentOS 很多年了,但从上月末(2024 年 6 月 30 日)开始,CentOS 停止维护了。因此,龙笑天提前已经基本将所有服务器的系统都更换为了Debian系统。
昨天,OpenSSH 爆出了一个高危漏洞:CVE-2024-6387,影响所有 linux 服务器系统。具体如下:
简而言之,利用此漏洞,你的服务器可以随便被人侵入当为肉鸡...
下面龙笑天在此以 Debian 12 系统为例,为大家送上具体的修复方法。
2 检测是否中了漏洞
输入命令:ssh -V
查看 OpenSSH 版本,如果看到 OpenSSH 的版本在上面列出的“受影响版本”里,就说明中招了!
输入命令后如下图:
可以看到龙笑天的 Debian 12 的 OpenSSH 版本为:9.2p1 Debian-2+deb12u2
,而根据 Debian 官方显示(见相关文章 1),9.2p1 Debian-2+deb12u3
才是安全的版本。因此,中招了,下面开始升级 OpenSSH 来修复漏洞。
3 升级 OpenSSH 方法
在升级系统软件包等操作前,一定要打好快照和备份好网站文件和数据库到本地先,以防万一!
3.1 添加 Security 安全源
输入命令:vim /etc/apt/sources.list
,然后像里面添加 Debian 官方 Security 安全源:
deb http://security.debian.org/debian-security bookworm-security main contrib non-free non-free-firmware
deb-src http://security.debian.org/debian-security bookworm-security main contrib non-free non-free-firmware
添加完成后,可以输入命令:cat /etc/apt/sources.list
来查看是否添加成功,如下图所示:
3.2 更新软件包列表
每次升级软件包前,都必须执行更新软件包列表命令:apt update
。
3.3 升级 OpenSSH 软件包
执行命令:apt upgrade openssh-server
。命令执行完成后,重启服务器或重启 SSH:systemctl restart ssh
。
3.4 再次查看 OpenSSH 版本
再次输入命令:ssh -V
查看 OpenSSH 版本,如下图:
可以看到,已经升级到了官方的 OpenSSH 安全版本:9.2p1 Debian-2+deb12u3
。
3.5 删除上面添加的 Security 安全源
输入命令:vim /etc/apt/sources.list
,然后删除里面的第 1 步里添加的那个 Security 安全源即可。
4 小技巧
4.1 安装 vim 命令
在执行 vim 命令时,可能提示命令不存在,那么就需要安装 vim 命令了。Debian 系统执行下面命令安装即可:
apt update
apt install vim -y
4.2 vim 里快速粘贴剪切板内容
在 vim 命令编辑文件时,如果想把一大段内容粘贴进去,同时按一下键盘上的 Shift 和 Insert 这 2 个键就行。
4.3 Debian 系统软件源国内镜像源
腾讯云:https://mirrors.cloud.tencent.com/debian/ 和 https://mirrors.cloud.tencent.com/debian-security
阿里云:https://mirrors.aliyun.com/debian 和 https://mirrors.aliyun.com/debian-security
清华大学:https://mirrors.tuna.tsinghua.edu.cn/debian/ 和 https://mirrors.tuna.tsinghua.edu.cn/debian-security
中国科技大学:https://mirrors.ustc.edu.cn/debian/ 和 https://mirrors.ustc.edu.cn/debian-security/
华为云:https://mirrors.huaweicloud.com/debian/ 和 https://mirrors.huaweicloud.com/debian-security/
更多镜像源:传送门
Debian 官方:http://deb.debian.org/debian 和 http://security.debian.org/debian-security
Debian 全球镜像站:https://www.debian.org/mirror/list
注意:国内源在国内服务器速度快,但其软件包可能不是最新版本。
5 相关文章
1.CVE-2024-6387 - Debian
2.关于 OpenSSH CVE-2024-6387 简单总结 - hostloc
3.ssh 爆漏洞了,手动更新 OpenSSH 教程 - hostloc
4.针对 OpenSSH CVE-2024-6387 漏洞的升级 | Laravel China 社区
5.尽快升级 openssh - 网络安全 - LINUX DO
6.Ubuntu 修复漏洞方法 - v2ex
还没有人赞赏,快来当第一个赞赏的人吧!
声明:本文为原创文章,版权归龙笑天下所有,欢迎分享本文,转载请保留出处!