debian9系统openssh漏洞升级教程

本文详细记录了在Debian9系统上修复OpenSSH安全漏洞的步骤,包括查看当前版本、备份、修改软件源、安装依赖、下载新版本OpenSSH包以及解决升级过程中遇到的各种问题。在升级完成后,还提供了避免服务卡顿和确保服务稳定运行的配置调整方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

提示:文章写完后,目录可以自动生成,如何生成可参考右边的帮助文档

debian9系统openssh升级教程

前言

服务器经常漏洞扫描,经常爆出openssh漏洞,解决方案就是升级openssh版本,本人小白一枚,近期收到DEBIAN9服务器openSSH漏洞修复的任务,在此记录分享,DEBIAN系统雷同

一、查看原先ssh版本,并且做好备份

ssh -V 先看看现在的版本
cp -rf /etc/ssh /etc/ssh.bak 备份原来的ssh到ssh.bak

二、修改系统软件源

1.打开并且编辑/etc/apt/sources.list

vi /etc/apt/sources.list

DEBIAN9系统修改为:

deb http://mirrors.aliyun.com/debian/ stretch main non-free contrib
deb-src http://mirrors.aliyun.com/debian/ stretch main non-free contrib
deb http://mirrors.aliyun.com/debian-security stretch/updates main
deb-src http://mirrors.aliyun.com/debian-security stretch/updates main
deb http://mirrors.aliyun.com/debian/ stretch-updates main non-free contrib
deb-src http://mirrors.aliyun.com/debian/ stretch-updates main non-free contrib
deb http://mirrors.aliyun.com/debian/ stretch-backports main non-free contrib
deb-src http://mirrors.aliyun.com/debian/ stretch-backports main non-free contrib

如果是DEBIAN10操作系统,或者DEBIAN9想要升级到debian10,则修改为:

deb http://mirrors.aliyun.com/debian/ buster main non-free contrib
deb http://mirrors.aliyun.com/debian-security buster/updates main
deb http://mirrors.aliyun.com/debian/ buster-updates main non-free contrib
deb http://mirrors.aliyun.com/debian/ buster-backports main non-free contrib
deb-src http://mirrors.aliyun.com/debian-security buster/updates main
deb-src http://mirrors.aliyun.com/debian/ buster main non-free contrib
deb-src http://mirrors.aliyun.com/debian/ buster-updates main non-free contrib
deb-src http://mirrors.aliyun.com/debian/ buster-backports main non-free contrib

注:stretch 代表debian9 ,buster代表DEBIAN10
更多源地址,参考https://blog.youkuaiyun.com/weixin_43978579/article/details/131302118

2.安装依赖,参考https://blog.youkuaiyun.com/GF_1205/article/details/115708434

首先执行

apt-get update

执行后,如果想要升级操作系统就执行

sudo apt-get dist-upgrade

如果本次只是想要升级openssh,那就不要执行sudo apt-get dist-upgrade

3.下载最新的新的openssh包

随便找一个空间足够的目录,下载一个不在漏洞清单中的版本进行下载,下载地址https://ftp.openbsd.org/pub/OpenBSD/OpenSSH/portable可以通过浏览器打开,找到自己要的版本,–no-check-certificate必须要加上

cd /usr
wget https://ftp.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-8.9p1.tar.gz --no-check-certificate

解压,并执行配置命令

tar zxf openssh-8.9p1.tar.gz
cd openssh-8.9p1
./configure --prefix=/usr --with-privsep-path=/var/empty/sshd/ \
       --sysconfdir=/etc/ssh --with-ssl-dir=/usr/local/openssl/ \
       --with-default-path=/usr/local/bin:/bin:/usr/bin \
       --with-superuser-path=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin \
       --with-pam --with-selinux --disable-strip --with-md5-passwords

执行后可能会报错,一般都是因为缺少支持,解决一个错误后再执行一次上面的命令,如果还有错误,继续解决错误,这样一直反复执行,解决,直到没有错误
如果报错 no acceptable C compiler found in $PATH 需要执行

apt-get install build-essential

如果报错中有pam字样,需要执行

apt-get install libpam0g-dev

如果报SElinux之类的不行就把上面configure里面的–with-selinux 去掉再执行看看
如果报错zlib.h missing,执行

 apt install zlib1g-dev -y  

如果报错working libcrypto not found 执行

apt install libssl-dev

如果不再报err错了,就执行

make
make install

至此,使用ssh -V,可以看到,版本升级到了新版本,但是,还有需要做的,这时执行

systemctl daemon-reload
systemctl restart sshd

时,发现,命令卡顿(应该是openssh兼容问题),需要修改ssh.service文件,执行

vi /lib/systemd/system/ssh.service

修改配置文件,找到并 注释 #Type=notify 这一行,在服务启动后,不用发消息给systemd,这样就不会不停重启服务。
,再执行

systemctl daemon-reload
systemctl restart sshd

至此全部升级完成

总结

提示:这里对文章进行总结:
例如:以上就是今天要讲的内容,本文仅仅简单介绍了debian9系统的openssh升级,openssh升级有失败的风险,一旦失败服务器断链,所以升级之前最好是打开telnet服务
大概类似

apt-get install telnetd
apt-get install xinetd

,这里不再细说telnet服务如何打开,网上也有相应教程。

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值