k0p*_*kus 6 compiling sftp curl make 18.04
我需要从 sftp 服务器下载文件。不幸的是,Ubuntu 中的 curl 版本
7.58.0-2ubuntu3.6 amd64
Run Code Online (Sandbox Code Playgroud)
不支持sftp。
我收到错误消息
Protocol "sftp" not supported or disabled in libcurl
Run Code Online (Sandbox Code Playgroud)
尝试下载文件时。因此,我想curl从源代码构建以允许 sftp。我如何做到这一点?
注意:从第三方来源安装软件存在安全风险。在执行这些步骤之前,请确保您信任来源。
首先,您需要安装libssh。
你需要一个 tarball,例如
https://www.libssh2.org/download/libssh2-1.8.2.tar.gz
Run Code Online (Sandbox Code Playgroud)
通过以下方式提取并安装它:
cd libssh2-1.8.1
./configure
make
sudo make install
Run Code Online (Sandbox Code Playgroud)
其次,确保卸载现有的 curl:
sudo apt purge curl
Run Code Online (Sandbox Code Playgroud)
我读过也建议卸载 curl 库,例如libcurl3-gnutls,但我注意到它有很多我不想丢失的依赖项,所以我保留了它。所以要小心卸载过程。
$ git clone https://github.com/curl/curl.git
Run Code Online (Sandbox Code Playgroud)
我用 commit hash 编译了它,b8f760319668548d93ab0c023633293514d8137如果你对当前的master.
该存储库包含一个GIT-INFO文件,其中包含有关如何构建它的有用信息,查看它可能会很有用,因为该过程将来可能会发生变化。
对我有用的是通过以下方式构建它:
./buildconf
./configure
./configure --disable-libcurl-option --disable-shared --with-libssh2=/usr/local
make
sudo make install
Run Code Online (Sandbox Code Playgroud)
(curl支持通过 卸载sudo make uninstall。如果您遇到问题或尝试不同的标志很有用。)
我没有使用共享库,因为我注意到 curl 在查找某些 curl 自己的命令时遇到问题并且在尝试运行它时失败,例如我看到如下错误:
curl: symbol lookup error: curl: undefined symbol: curl_url_cleanup
curl: error while loading shared libraries: libcurl.so.4: cannot open shared object file: No such file or directory
Run Code Online (Sandbox Code Playgroud)
然而,通过上述方法,我现在有一个支持 sftp 的工作 curl,因为 sftp 出现在支持的协议中:
$ curl -V
curl 7.64.1-DEV (x86_64-pc-linux-gnu) libcurl/7.64.1-DEV OpenSSL/1.1.0g zlib/1.2.11 libssh2/1.8.1
Release-Date: [unreleased]
Protocols: dict file ftp ftps gopher http https imap imaps pop3 pop3s rtsp scp sftp smb smbs smtp smtps telnet tftp
Features: AsynchDNS HTTPS-proxy IPv6 Largefile libz NTLM NTLM_WB SSL TLS-SRP UnixSockets
Run Code Online (Sandbox Code Playgroud)
我可以确认它从 sftp 服务器下载文件。
资料来源:我通过以下方式找到了必要的步骤:
| 归档时间: |
|
| 查看次数: |
6806 次 |
| 最近记录: |