openssh升级处理

本文档详细记录了在升级OpenSSH时遇到的各种问题及其解决方案,包括处理依赖包缺失、缺少用例文件、文件未包含在包中、ChangeLog.gssapi缺失、包名错误以及因无法重启进程导致安装失败等。通过一系列的修改和调整,成功打包出一个可正常使用的OpenSSH新版本包。

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

需求

升级openssh的包,因为有漏洞的爆出,需要更新openssh的版本

处理

系统自带的版本

openssh-client_7.2p2

我们使用这个版本的打包的debian文件,下载地址

wget https://launchpad.net/ubuntu/+archive/primary/+sourcefiles/openssh/1:7.2p2-4/openssh_7.2p2-4.debian.tar.xz

下载8.4的源码

wget http://archive.ubuntu.com/ubuntu/pool/main/o/openssh/openssh_8.2p1.orig.tar.gz

上面的是本次打包的openssh的版本

下载8.2的debian文件

wget  http://archive.ubuntu.com/ubuntu/pool/main/o/openssh/openssh_8.2p1-4ubuntu0.2.debian.tar.xz

8.2这个版本的debian文件只用来比对,不使用,用于后面缺文件的参考

准备系统好源文件

root@qilin1:/etc/apt# cat sources.list
##deb file:///media/kylin/Kylin-4.0.2 juniper main
#deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/  xenial main multiverse restricted universe
deb http://archive.kylinos.cn/kylin/KYLIN-ALL 4.0.2-server main restricted universe multiverse

根据需要的情况在上面的地址之间切换,基本上都可以在原始源里面找到

tar -xvf openssh_7.2p2-4.debian.tar.xz
tar -xvf openssh_8.2p1.orig.tar.gz
cp -ra debian/ openssh-8.2p1/

开始打包

dpkg-buildpackage -uc -us -b

问题:提示缺依赖包

根据提示安装依赖包

apt-get install libsystemd-dev libaudit-dev dh-autoreconf  libedit-dev dh-exec libselinux1-dev libssl-dev libwrap0-dev heimdal-dev dh-systemd

单独下载

wget http://archive.kylinos.cn/kylin/KYLIN-ALL/pool/main/p/pam/libpam0g-dev_1.1.8-3.2kord3k14_arm64.deb
dpkg -i libpam0g-dev_1.1.8-3.2kord3k14_arm64.deb

再次执行

dpkg-buildpackage -uc -us -b

就开始打包了

问题:提示测试里面缺少用例文件

输出的提示如下

test_sshbuf: ...................................................................................................... 103 tests ok
test_sshkey: .......................................................................................... 90 tests ok
test_bitmap: .. 2 tests ok
/bin/sh: 9: /root/openssh/openssh-8.2p1/build-deb/regress/unittests/conversion/test_conversion: not found
Makefile:245: recipe for target 'unit' failed
make[2]: *** [unit] Error 127
make[2]: Leaving directory '/root/openssh/openssh-8.2p1/build-deb/regress'
debian/rules:155: recipe for target 'override_dh_auto_test-arch' failed
make[1]: *** [override_dh_auto_test-arch] Error 2

关闭unittest

root@qilin1:~/openssh/openssh-8.2p1# vim debian/rules
修改配置文件
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
  RUN_TESTS := yes
else
  RUN_TESTS :=
endif

改成

ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
  RUN_TESTS := no
else
  RUN_TESTS :=
endif

再次执行

dpkg-buildpackage -uc -us -b

问题:有文件找不到,有文件没包含到包

make[1]: Leaving directory '/root/openssh/openssh-8.2p1'
   debian/rules override_dh_install-arch
make[1]: Entering directory '/root/openssh/openssh-8.2p1'
rm -f debian/tmp/etc/ssh/sshd_config
dh_install -Nopenssh-client-udeb -Nopenssh-server-udeb --fail-missing
dh_install: openssh-server missing files: usr/share/man/man5/authorized_keys.5
dh_install: usr/share/man/man8/ssh-sk-helper.8 exists in debian/tmp but is not installed to anywhere
dh_install: usr/lib/openssh/ssh-sk-helper exists in debian/tmp but is not installed to anywhere
dh_install: missing files, aborting
debian/rules:187: recipe for target 'override_dh_install-arch' failed
make[1]: *** [override_dh_install-arch] Error 2
make[1]: Leaving directory '/root/openssh/openssh-8.2p1'
debian/rules:122: recipe for target 'binary' failed
添加到包文件

参考8.2的debian文件
修改文件

root@qilin1:~/openssh/openssh-8.2p1# vim debian/openssh-client.install

添加

usr/lib/openssh/ssh-sk-helper
usr/share/man/man8/ssh-sk-helper.8
移除一个man文件
root@qilin1:~/openssh/openssh-8.2p1# vim debian/openssh-server.install

删除

usr/share/man/man5/authorized_keys.5

再次打包

dpkg-buildpackage -uc -us -b

问题:提示没有ChangeLog.gssapi

出错提示如下

make[1]: Leaving directory '/root/openssh/openssh-8.2p1'
   debian/rules override_dh_installdocs
make[1]: Entering directory '/root/openssh/openssh-8.2p1'
dh_installdocs \
	-Nopenssh-client-ssh1 -Nopenssh-server -Nopenssh-sftp-server
cp: cannot stat 'ChangeLog.gssapi': No such file or directory
dh_installdocs: cp --reflink=auto -a ChangeLog.gssapi debian/openssh-client/usr/share/doc/openssh-client returned exit code 1
debian/rules:207: recipe for target 'override_dh_installdocs' failed
make[1]: *** [override_dh_installdocs] Error 2
make[1]: Leaving directory '/root/openssh/openssh-8.2p1'
debian/rules:122: recipe for target 'binary' failed
make: *** [binary] Error 2
dpkg-buildpackage: error: debian/rules binary gave error exit status 2

删除掉相关的文件即可

修改配置文件

root@qilin1:~/openssh/openssh-8.2p1# vim debian/openssh-client.docs

删除

ChangeLog.gssapi

再次打包

dpkg-buildpackage -uc -us -b

问题:输出的包名称不对

打包出来的名称不对,需要修改

root@qilin1:~/openssh/openssh-8.2p1# vim debian/changelog

修改

openssh (1:7.2p2-4) unstable; urgency=medium

  * Drop dependency on libnss-files-udeb (closes: #819686).
  * Policy version 3.9.7: no changes required.

修改为

openssh (1:8.2p1-4) unstable; urgency=medium

  * Drop dependency on libnss-files-udeb (closes: #819686).
  * Policy version 3.9.7: no changes required.

deb使用的是change log进行的包名称控制

现在的包打出来,存在一个问题,安装的时候需要重启ssh,重启就会卡死,这个地方是官方存在一个bug,我们需要处理下

问题:打的包无法安装(无法重启进程引起)

修改源码sshd.c

在开头添加

#include <systemd/sd-daemon.h>

在这个server_accept_loop 函数调用行的上面
               /* Accept a connection and return in a forked child */
                server_accept_loop(&sock_in, &sock_out,
                    &newsock, config_s);
        }

添加

sd_notify(0, "READY=1");

修改后如下

                /* Signal systemd that we are ready to accept connections */
                sd_notify(0, "READY=1");
                /* Accept a connection and return in a forked child */
                server_accept_loop(&sock_in, &sock_out,
                    &newsock, config_s);

代码修改后,这里存在一个问题,上面的函数编译的时候找不到systemd/sd-daemon.h这个,需要在编译的地方加入库的引用

这个地方的库引用又是其它文件设置的,所以这里需要修改下

root@qilin1:~/openssh/openssh-8.2p1# vim configure.ac

if test "x$openssl" = "xyes" ; then
        LIBS="-lcrypto  $LIBS"
        AC_TRY_LINK_FUNC([RAND_add], ,

修改为

if test "x$openssl" = "xyes" ; then
        LIBS="-lcrypto -lsystemd $LIBS"
        AC_TRY_LINK_FUNC([RAND_add], ,

添加了一个 -lsystemd

再次编译

得到的包只用取下面的即可

root@qilin1:~/openssh/good# ll
total 964
drwxr-xr-x 2 root root   4096 Oct 20 16:05 ./
drwxr-xr-x 6 root root   4096 Oct 20 16:05 ../
-rw-r--r-- 1 root root 625760 Oct 20 16:04 openssh-client_8.2p1-4_arm64.deb
-rw-r--r-- 1 root root 303494 Oct 20 16:04 openssh-server_8.2p1-4_arm64.deb
-rw-r--r-- 1 root root  41852 Oct 20 16:04 openssh-sftp-server_8.2p1-4_arm64.deb

总结

按照上面的步骤以后就可以打出一个可以使用的包,里面比较关键的是后面的卡死的问题,这个应该后面的版本都通用的,是进程没有通知systemd引起的
其它的就是一些打包过程中版本变化的一些处理

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

武汉磨磨

打赏是写出更好教程的鼓励

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值