麒麟v10系统openssh升级OpenSSH_10.0p2-OpenSSL 3.4.2

奥黛丽·逐爱者
2025-09-17 / 0 评论 / 36 阅读 / 正在检测是否收录...

查看版本

[root@KylinV10 ~]# ssh -V
OpenSSH_8.2p1, OpenSSL 1.1.1f  31 Mar 2020

mfnv0pz1.png

下载openssl

升级openssl

#解压gz包
tar -zxvf openssl-3.4.1.tar.gz
 
#进入到文件夹
cd openssl-3.4.2/
 

# 1. 回到源码目录
cd /root/openssl-3.4.2

# 2. 重新配置(共享库 + 安装前缀)
make distclean
./config shared zlib -fPIC --prefix=/usr/local/openssl

# 3. 编译 & 安装
make -j$(nproc)
make install

# 4. 确认库已生成
 ~~错误ls -l /usr/local/openssl/lib/libcrypto.so.3~~ 
ls -l /usr/local/openssl/lib64/libcrypto.so.3
# 5. 注册到系统缓存
echo '/usr/local/openssl/lib64' > /etc/ld.so.conf.d/openssl-3.4.2.conf
ldconfig
··························································
# 1. 修正路径
echo '/usr/local/openssl/lib64' > /etc/ld.so.conf.d/openssl-3.4.2.conf

# 2. 刷新缓存
ldconfig

# 3. 验证系统已识别
ldconfig -p | grep libcrypto.so.3

必须出现:
libcrypto.so.3 (libc6,x86-64) => /usr/local/openssl/lib64/libcrypto.so.3

查看openssl版本

openssl version

然后再回到 openssh 目录:

cd /root/openssh-10.0p1
make distclean
export PATH="/usr/local/openssl/bin:$PATH"
export PKG_CONFIG_PATH="/usr/local/openssl/lib64/pkgconfig"
./configure \
  --prefix=/usr/local/openssh \
  --sysconfdir=/etc/ssh \
  --with-ssl-dir=/usr/local/openssl \
  --with-zlib --with-pam

configure 已经 顺利通过!
下一步直接编译安装即可:

make -j$(nproc) 
make install

1.停用旧服务

systemctl stop sshd
systemctl disable sshhd
systemctl daemon-reload
  1. 删掉系统 unit(不管有没有)
rm -f /usr/lib/systemd/system/ssh*.service
  1. 建新版配置目录 & 最小配置
mkdir -p /etc/ssh                          # 新版配置统一放这里
cp /usr/local/openssh/etc/sshd_config /etc/ssh/sshd_config

# 最小必改项(麒麟 V10 必须)
sed -i 's/^#PermitRootLogin.*/PermitRootLogin yes/'      /etc/ssh/sshd_config
sed -i 's/^#PubkeyAuthentication.*/PubkeyAuthentication yes/' /etc/ssh/sshd_config
sed -i 's/^#PasswordAuthentication.*/PasswordAuthentication yes/' /etc/ssh/sshd_config
  1. 生成主机密钥(一次即可)
/usr/local/openssh/bin/ssh-keygen -A
  1. 写 systemd 单元(麒麟 V10 通用)
cat >/etc/systemd/system/sshd.service <<'EOF'
[Unit]
Description=OpenSSH Server
After=network.target

[Service]
Type=simple
ExecStart=/usr/local/openssh/sbin/sshd -D -f /etc/ssh/sshd_config
ExecReload=/bin/kill -HUP $MAINPID
Restart=always
RestartSec=42s

[Install]
WantedBy=multi-user.target
EOF
  1. 注册 & 启动
systemctl daemon-reload
systemctl enable --now sshd
  1. 验证(另开终端)
ssh -V               # 客户端版本
ssh 127.0.0.1        # 本机再开一个会话,确认能登录
  1. 可选:保留旧二进制当救命稻草
mv /usr/sbin/sshd /usr/sbin/sshd.bak
ln -s /usr/local/openssh/sbin/sshd /usr/sbin/sshd
  1. 系统变量
echo 'export PATH=/usr/local/openssh/bin:$PATH' >> /etc/profile
source /etc/profile

验证(另开终端)
ssh -V
ssh 127.0.0.1
mfnyxira.png

0

评论 (0)

取消