OpenSSL 版本问题导致 SSH 服务无法正常启动的修复方法
故障如上图所示,启动 ssh 服务时抛出如下错误
OpenSSL version mismatch build against xxxxx you have xxxxxx
这是因为 OpenSSL 与 OpenSSH 服务的版本号不匹配导致的此类问题,经检查 OpenSSL 版本高于 OpenSSH 所需要的版本。
解决方案
升级OpenSSH服务
检查并安装相关依赖以及编译工具
1 | sudo apt install build-essential checkinstall zlib1g-dev libpam0g-dev |
编译安装 OpenSSH
下载 OpenSSH 源码包并解压
1 | wget https://cdn.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-9.9p1.tar.gz |
使用 configure
脚本配置 OpenSSH
1 | ./configure --prefix=$(pwd)/build --sysconfdir=$(pwd)/build/etc/ssh --with-ssl-dir=/usr --with-pam --with-md5-passwords |
编译安装 OpenSSH
1 | sudo make |
更新 sshd
二进制文件
需要先将旧版本的二进制文件备份一下
1 | cp -a /usr/sbin/sshd "/usr/sbin/.sshd_old_$(date +%Y%m%d_%H%M%S)" |
将新编译的 sshd
二进制文件 复制到 /usr/sbin/
目录
1 | cd openssh-9.9p1/build |
验证版本号
1 | sshd -V |
启动服务
1 | sshd -t |
All articles on this blog are licensed under CC BY-NC-SA 4.0 unless otherwise stated.
Comments