麒麟V10 x86系统升级openssh
前言
漏洞扫描后,需要升级openssh来修复漏洞,升级过程中遇到一些问题记录。
操作系统:麒麟V10 x86
openssh版本:OpenSSH_8.2p1, OpenSSL 1.1.1f
升级过程
前期准备
因为是内网环境,需要在同系统的互联网系统中拉取依赖包:
mkdir openssh-upgrade/packages && cd openssh-upgrade/packages
dnf install --downloadonly --downloaddir ./ gcc gcc-c++ make perl zlib-devel pam-devel libselinux-devel
cd ../
wget https://github.com/openssl/openssl/releases/download/openssl-3.5.1/openssl-3.5.1.tar.gz
wget https://cdn.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-10.0p2.tar.gz
cd ../
tar zcf openssh-upgrade.tar.gz openssh-upgrade
离线升级包就下载完成了, 导入到内网服务器。
开始升级
- 安装依赖包
tar xf openssh-upgrade.tar.gz
mv /etc/yum.repos.d/kylin_x86_64.repo /etc/yum.repos.d/kylin_x86_64.repo_bak
dnf localinstall -y openssh-upgrade/packages/*.rpm
- 编译openssl
cd openssh-upgrade
tar xf openssl-3.5.1.tar.gz && cd openssl-3.5.1
./config --prefix=/usr/local/openssl3 --openssldir=/usr/local/openssl3 shared zlib
make -j$(nproc)
make install
#注册新库路径
echo "/usr/local/openssl3/lib64" > /etc/ld.so.conf.d/openssl3.conf
ldconfig
#验证
/usr/local/openssl3/bin/openssl version
OpenSSL 3.5.1 1 Jul 2025 (Library: OpenSSL 3.5.1 1 Jul 2025)
- 编译openssh
cd openssh-upgrade
tar xf openssh-10.0p2.tar.gz && cd openssh-10.0p1
./configure --prefix=/usr --sysconfdir=/etc/ssh --with-pam --with-zlib --with-ssl-dir=/usr/local/openssl3 --with-privsep-path=/var/lib/sshd
make -j$(nproc)
make install
#查看版本
sshd -V
OpenSSH_10.0p2, OpenSSL 3.5.1 1 Jul 2025
#新版 OpenSSH 10.0 不认麒麟原配置中的私有/废弃选项,sshd -t 报错如下:
sshd -t
/etc/ssh/sshd_config line 80: Unsupported option GSSAPIAuthentication
/etc/ssh/sshd_config line 81: Unsupported option GSSAPICleanupCredentials
/etc/ssh/sshd_config line 147: Deprecated option RSAAuthentication
/etc/ssh/sshd_config line 149: Deprecated option RhostsRSAAuthentication
/etc/ssh/sshd_config: line 170: Bad configuration option: GSSAPIKexAlgorithms
/etc/ssh/sshd_config: terminating, 1 bad configuration options
#处理:编辑 /etc/ssh/sshd_config,将以下行行首加 # 注释:
sed -i -E 's/^([[:space:]]*)GSSAPIAuthentication/\1#GSSAPIAuthentication/' /etc/ssh/sshd_config
sed -i -E 's/^([[:space:]]*)GSSAPICleanupCredentials/\1#GSSAPICleanupCredentials/' /etc/ssh/sshd_config
sed -i -E 's/^([[:space:]]*)RSAAuthentication/\1#RSAAuthentication/' /etc/ssh/sshd_config
sed -i -E 's/^([[:space:]]*)RhostsRSAAuthentication/\1#RhostsRSAAuthentication/' /etc/ssh/sshd_config
sed -i -E 's/^([[:space:]]*)GSSAPIKexAlgorithms/\1#GSSAPIKexAlgorithms/' /etc/ssh/sshd_config
#再次检测
sshd -t
#检查系统加密策略是否注入该选项:
grep -n GSSAPIKexAlgorithms /etc/crypto-policies/back-ends/openssh.config
若存在,同样注释掉该行。
sed -i -E 's/^([[:space:]]*)GSSAPIKexAlgorithms/\1#GSSAPIKexAlgorithms/' /etc/crypto-policies/back-ends/openssh.config
#重启服务
systemctl restart sshd
测试rsync
[root@localhost ~]# rsync -av --progress kylinv10-openssh.zip 10.0.10.13:/tmp
/etc/ssh/ssh_config.d/05-redhat.conf line 7: Unsupported option "gssapiauthentication"
/etc/ssh/ssh_config.d/05-redhat.conf line 7: Unsupported option "gssapiauthentication"
The authenticity of host '10.0.10.13 (10.0.10.13)' can't be established.
ED25519 key fingerprint is SHA256:bKEeMa/A7xp2cjQA5eZI9c5Bvq1iPBfHTKhkjD08zS0.
This key is not known by any other names.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
上来就提示 /etc/ssh/ssh_config.d/05-redhat.conf line 7: Unsupported option "gssapiauthentication"
这里临时的解决办法就是注释掉。
vim /etc/ssh/ssh_config.d/05-redhat.conf
# The options here are in the "Match final block" to be applied as the last
# options and could be potentially overwritten by the user configuration
Match final all
# Follow system-wide Crypto Policy, if defined:
#Include /etc/crypto-policies/back-ends/openssh.config #注释掉引用
#GSSAPIAuthentication yes #注释掉开启
# If this option is set to yes then remote X11 clients will have full access
# to the original X11 display. As virtually no X11 client supports the untrusted
# mode correctly we set this to yes.
ForwardX11Trusted yes
# Send locale-related environment variables
SendEnv LANG LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY LC_MESSAGES
SendEnv LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT
SendEnv LC_IDENTIFICATION LC_ALL LANGUAGE
SendEnv XMODIFIERS
# Uncomment this if you want to use .local domain
# Host *.local
再次使用rsync进行测试
rsync -av --progress kylinv10-openssh.zip 10.0.10.13:/tmp
Authorized users only. All activities may be monitored and reported.
root@10.0.10.13's password:
sending incremental file list
kylinv10-openssh.zip
110,541,974 100% 52.48MB/s 0:00:02 (xfr#1, to-chk=0/1)
sent 110,569,061 bytes received 35 bytes 14,742,546.13 bytes/sec
total size is 110,541,974 speedup is 1.00
问题解决,这里主要是因为配置文件造成。我们在编译openssh会生成新的配置,但是并没有覆盖掉旧版本的配置文件,所以需要我们手动进行将旧版本的 /etc/ssh 重命名为 /etc/ssh-old 这样就不需要手动删除新版本废弃的选项,操作如下:
正确的编译流程
(1)安装依赖包
(2)编译安装openssl
前两步都没有问题, 到编译openssh时就需要注意。
#重命名旧版本的配置文件
mv /etc/ssh /etc/ssh-old
#编译openssh
cd openssh-upgrade
tar xf openssh-10.0p2.tar.gz && cd openssh-10.0p1
./configure --prefix=/usr --sysconfdir=/etc/ssh --with-pam --with-zlib --with-ssl-dir=/usr/local/openssl3 --with-privsep-path=/var/lib/sshd
make -j$(nproc)
make install
#查看版本
sshd -V
OpenSSH_10.0p2, OpenSSL 3.5.1 1 Jul 2025
#检测配置文件语法
sshd -t
没有任何提示则表示正确
#注意:如果这里需要开启root用户使用ssh登录,则需要修改配置
vim /etc/ssh/sshd_config
...
PermitRootLogin yes
...
#重启服务
systemctl restart sshd
#测试rsync
rsync -av --progress kylinv10-openssh.zip 10.0.10.13:/tmp/
The authenticity of host '10.0.10.13 (10.0.10.13)' can't be established.
ED25519 key fingerprint is SHA256:+veBYMok/utBKjIysbhkFLJcTkGN8uewt3kUzGW8gvw.
This key is not known by any other names.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
这样的步骤走下来比上面在旧配置文件上进行修改要标准的多。
补充说明
如果已经采用第一种方式进行了升级操作,可以进行如下修复操作:
mv /etc/ssh /etc/ssh-old
cd openssh-10.0p1
make install

浙公网安备 33010602011771号