构建OpenSSH时缺少OpenSSL头文件

11

我想从源代码构建特定版本的OpenSSH,并使用特定版本的OpenSSL,但是我遇到了以下错误:

mkdir /tmp/ssh
cp openssh-6.7p1.tar.gz /tmp/ssh
cp openssl-1.0.1l.tar.gz /tmp/ssh
cd /tmp/ssh
tar zxvf openssl-1.0.1l.tar.gz
cd openssl-1.0.1l
./config --prefix=/tmp/ssh
make
make install
cd ..
tar zxvf openssh-6.7p1.tar.gz
cd openssh-6.7p1
./configure --with-ssl-dir=/tmp/ssh --prefix=/tmp/ssh

...
checking openssl/opensslv.h usability... no
checking openssl/opensslv.h presence... no
checking for openssl/opensslv.h... no
configure: error: *** OpenSSL headers missing - please install first or check config.log ***

openSSH的配置脚本有bug吗?还是我需要更改一些命令?

4个回答

12

以下是一种不需要向./configure发送标志的方法。您需要先安装OpenSSL。在此处获取最新的tarball

./config
make
make test
make install

然后安装libssl-dev
apt-get install libssl-dev

接着您可以尝试重新安装OpenSSH:

cd openssh-[version]
./configure
make
make install

3

ftp://ftp.ca.openbsd.org/pub/OpenBSD/OpenSSH/portable/INSTALL 中提到:

LibreSSL/OpenSSL 应该编译成一个位置无关库(即使用 -fPIC),否则 OpenSSH 将无法链接它。如果你必须使用一个非位置无关的 libcrypto,那么你可能需要配置 OpenSSH --without-pie。

以下命令将不再导致 "OpenSSL headers missing" 错误:

tar zxvf openssl-1.0.1l.tar.gz
cd openssl-1.0.1l
./config --prefix=/tmp/ssh
make
make install
cd ..
tar zxvf openssh-6.7p1.tar.gz
cd openssh-6.7p1
./configure --with-ssl-dir=/tmp/ssh --prefix=/tmp/ssh --without-pie

1
另外,也可以使用"./config --prefix=/tmp/ssh shared"和"LD_LIBRARY_PATH=/tmp/ssh/lib ./configure --prefix=/tmp/ssh --with-ssl-dir=/tmp/ssh"。 - name
我按照你的代码操作并且 ./configure 成功了,无论是否带上 --without-pie。但是在 make 过程中出现了以下情况: - shih alex
EVP_CIPHER_CTX evp; ^ Makefile:152: recipe for target 'ssh_api.o' failed``` - shih alex
我就是找不到问题所在。你能帮我吗?我的目的是使用非sudo特权用户安装openssh-server,我的GPU服务器类似于这样,并且我想启用SSH和SFTP,以便我可以将服务器用作Jetbrains Pycharm中的SSH远程解释器。 - shih alex

1

这里是解决 OpenSSL 头文件缺失错误的方法。

git clone https://github.com/openssl/openssl.git
cd openssl
./Configure
make
make install

现在将安装OpenSSL,您将不再收到缺少OpenSSL头文件的消息。


0
openSSH的配置脚本中是否存在错误,还是我需要更改任何命令?根据安装OpenSSL和OpenSSH

If 'configure' can't find ssl, change the configure command to:

./configure --prefix=/usr --with-ssl-dir=/usr/local/ssl --with-tcp-wrappers
以上意味着OpenSSL头文件位于/usr/local/ssl/include,库文件位于/usr/local/ssl/lib。我认为你需要将路径更改为/tmp/ssh

来自:

cd openssl-1.0.1l
./config --prefix=/tmp/ssh
...

我认为你应该使用:

cd openssl-1.0.1l
./config --openssldir=/tmp/ssh/openssl
...

另请参阅 OpenSSL 维基上的 编译和安装。您可能希望使用其他选项,例如 enable-ec_nistp_64_gcc_128


使用位于/tmp/ssh/openssl的OpenSSL,然后执行以下操作:

cd openssh-6.7p1
./configure --with-ssl-dir=/tmp/ssh/openssl --prefix=/tmp/ssh
...

使用非系统提供的OpenSSL可能会出现问题。因此,您可能还想查看使用RPATH构建OpenSSL?。您可能还想使用RPATHs构建OpenSSH。


将"./config --prefix=/tmp/ssh"更改为"./config --openssldir=/tmp/ssh/openssl",并将"./configure --with-ssl-dir=/tmp/ssh --prefix=/tmp/ssh"更改为"./configure --with-ssl-dir=/tmp/ssh/openssl --prefix=/tmp/ssh"会导致相同的“缺少OpenSSL头文件”错误。 - name

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接