Skip to content

源码安装 OpenSSH

源码仓库

说明

警告

  1. 原则上 仅安装必要的软件最小化安装所需软件对系统影响最小

CentOS 系列编译安装

  • 本示例以 CentOS 7.9.2009OpenSSH V_9_3_P2 为例

警告

  1. CentOS 7.9.2009 的安装源中,截止 2024-12-04 只能下载到 OpenSSL 1.0.2k-fips
  2. OpenSSH V_9_3_P2 以后的版本(不包含)所需 OpenSSL 最低要求 1.1.1
  3. 如果要安装 OpenSSH V_9_3_P2 以后的版本(不包含),可根据 openssl.md 安装 OpenSSL 1.1.1w
    • 注意:CentOS 7.9.2009 不支持 OpenSSH V_9_9_P1 及之后的版本
    • 注意:CentOS 8.0.1905 支持 OpenSSH V_9_9_P1

下载源码

  • 下载所需安装版本的标签即可

解压

shell
# yum -y install tar
tar -zxvf openssh-portable-V_9_3_P2.tar.gz
shell
cd openssh-portable-V_9_3_P2

可选安装 autoconf

shell
[root@centos7-9 openssh-portable-V_9_3_P2]# autoreconf
-bash: autoreconf: command not found
[root@centos7-9 openssh-portable-V_9_3_P2]#
shell
yum -y install autoconf

# 安装完成,即可正常执行 autoreconf 命令

可选安装 automake

shell
[root@centos7-9 openssh-portable-V_9_3_P2]# autoreconf
Can't exec "aclocal": No such file or directory at /usr/share/autoconf/Autom4te/FileUtils.pm line 326.
autoreconf: failed to run aclocal: No such file or directory
[root@centos7-9 openssh-portable-V_9_3_P2]#
shell
yum -y install automake

# 安装完成,即可正常执行 autoreconf 命令

可选安装 gcc

shell
[root@centos7-9 openssh-portable-V_9_3_P2]# ./configure 
checking for cc... no
checking for gcc... no
checking for clang... no
configure: error: in `/root/openssh-portable-V_9_3_P2':
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details
[root@centos7-9 openssh-portable-V_9_3_P2]#
shell
yum -y install gcc

# 安装完成,即可正常执行 ./configure 命令

可选安装 zlib-devel

shell
[root@centos7-9 openssh-portable-V_9_3_P2]# ./configure 

......

configure: error: *** zlib.h missing - please install first or check config.log ***
[root@centos7-9 openssh-portable-V_9_3_P2]#
shell
yum -y install zlib-devel

# 安装完成,即可正常执行 ./configure 命令

可选安装 openssl-devel

shell
[root@centos7-9 openssh-portable-V_9_3_P2]# ./configure 

......

checking for openssl... /usr/bin/openssl
configure: error: *** working libcrypto not found, check config.log
[root@centos7-9 openssh-portable-V_9_3_P2]#
shell
yum -y install openssl-devel

# 安装完成,即可正常执行 ./configure 命令

可选安装 make

shell
[root@centos7-9 openssh-portable-V_9_3_P2]# make
-bash: make: command not found
[root@centos7-9 openssh-portable-V_9_3_P2]#
shell
yum -y install make

# 安装完成,即可正常执行 make 命令

完整安装命令

shell
yum -y install autoconf automake gcc zlib-devel openssl-devel make
autoreconf
./configure
make && make install
source /etc/profile
ssh -V
shell
yum -y install autoconf automake gcc zlib-devel openssl-devel make
autoreconf
./configure
make && make tests && make install
source /etc/profile
ssh -V