cURL 不接受 sftp

cURL 不接受 sftp

我正在尝试使用 cURL 设置 SFTP,并按照以下说明进行操作Andrew Berls 的博客,但如果我运行该命令,curl -V我会得到以下输出:

curl 7.57.0 (i686-pc-linux-gnu) libcurl/7.47.0 OpenSSL/1.0.2g zlib/1.2.8 libidn/1.32 librtmp/2.3
Release-Date: 2017-11-29
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtmp rtsp smb smbs smtp smtps telnet tftp
Features: AsynchDNS IDN IPv6 Largefile GSS-API Kerberos SPNEGO NTLM NTLM_WB SSL libz TLS-SRP UnixSockets

那么由于某种原因,sftp 没有出现,我该如何解决这个问题?

make install这是我按照上述说明运行时的错误日志:

Making install in lib
make[1]: Entering directory '/root/curl-7.47.0/lib'
  CC       vtls/libcurl_la-openssl.lo
vtls/openssl.c: In function 'Curl_ossl_cleanup':
vtls/openssl.c:758:3: warning: 'ERR_remove_thread_state' is deprecated [-Wdeprecated-declarations]
   ERR_remove_thread_state(NULL);
   ^
In file included from /usr/include/openssl/ui.h:13:0,
                 from /usr/include/openssl/engine.h:29,
                 from ../lib/urldata.h:88,
                 from vtls/openssl.c:41:
/usr/include/openssl/err.h:247:1: note: declared here
 DEPRECATEDIN_1_1_0(void ERR_remove_thread_state(void *))
 ^
vtls/openssl.c: In function 'verifyhost':
vtls/openssl.c:1095:9: warning: 'ASN1_STRING_data' is deprecated [-Wdeprecated-declarations]
         const char *altptr = (char *)ASN1_STRING_data(check->d.ia5);
         ^
In file included from /usr/include/openssl/bn.h:31:0,
                 from /usr/include/openssl/asn1.h:24,
                 from /usr/include/openssl/objects.h:916,
                 from /usr/include/openssl/evp.h:27,
                 from /usr/include/openssl/x509.h:23,
                 from /usr/include/openssl/ssl.h:50,
                 from ../lib/urldata.h:86,
                 from vtls/openssl.c:41:
/usr/include/openssl/asn1.h:553:1: note: declared here
 DEPRECATEDIN_1_1_0(unsigned char *ASN1_STRING_data(ASN1_STRING *x))
 ^
vtls/openssl.c:1178:15: warning: 'ASN1_STRING_data' is deprecated [-Wdeprecated-declarations]
               memcpy(peer_CN, ASN1_STRING_data(tmp), j);
               ^
In file included from /usr/include/openssl/bn.h:31:0,
                 from /usr/include/openssl/asn1.h:24,
                 from /usr/include/openssl/objects.h:916,
                 from /usr/include/openssl/evp.h:27,
                 from /usr/include/openssl/x509.h:23,
                 from /usr/include/openssl/ssl.h:50,
                 from ../lib/urldata.h:86,
                 from vtls/openssl.c:41:
/usr/include/openssl/asn1.h:553:1: note: declared here
 DEPRECATEDIN_1_1_0(unsigned char *ASN1_STRING_data(ASN1_STRING *x))
 ^
vtls/openssl.c: In function 'get_cert_chain':
vtls/openssl.c:2353:29: warning: passing argument 1 of 'X509_get0_signature' from incompatible pointer type [-Wincompatible-pointer-types]
         X509_get0_signature(&psig, &palg, x);
                             ^
In file included from /usr/include/openssl/ssl.h:50:0,
                 from ../lib/urldata.h:86,
                 from vtls/openssl.c:41:
/usr/include/openssl/x509.h:552:6: note: expected 'const ASN1_BIT_STRING ** {aka const struct asn1_string_st **}' but argument is of type 'ASN1_BIT_STRING ** {aka struct asn1_string_st **}'
 void X509_get0_signature(const ASN1_BIT_STRING **psig,
      ^
vtls/openssl.c:2353:36: warning: passing argument 2 of 'X509_get0_signature' from incompatible pointer type [-Wincompatible-pointer-types]
         X509_get0_signature(&psig, &palg, x);
                                    ^
In file included from /usr/include/openssl/ssl.h:50:0,
                 from ../lib/urldata.h:86,
                 from vtls/openssl.c:41:
/usr/include/openssl/x509.h:552:6: note: expected 'const X509_ALGOR ** {aka const struct X509_algor_st **}' but argument is of type 'X509_ALGOR ** {aka struct X509_algor_st **}'
 void X509_get0_signature(const ASN1_BIT_STRING **psig,
      ^
vtls/openssl.c:2360:27: warning: passing argument 3 of 'X509V3_ext' discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
       X509V3_ext(data, i, X509_get0_extensions(x));
                           ^
vtls/openssl.c:2246:12: note: expected 'struct stack_st_X509_EXTENSION *' but argument is of type 'const struct stack_st_X509_EXTENSION *'
 static int X509V3_ext(struct SessionHandle *data,
            ^
vtls/openssl.c:2389:20: error: dereferencing pointer to incomplete type 'EVP_PKEY {aka struct evp_pkey_st}'
       switch(pubkey->type) {
                    ^
Makefile:1868: recipe for target 'vtls/libcurl_la-openssl.lo' failed
make[1]: *** [vtls/libcurl_la-openssl.lo] Error 1
make[1]: Leaving directory '/root/curl-7.47.0/lib'
Makefile:880: recipe for target 'install-recursive' failed
make: *** [install-recursive] Error 1

答案1

您提供的链接,根据第一条评论,curl 需要从源代码安装并使用--disabled-shared以下命令运行./configure

首先,获取 curl 源:

apt source curl

然后进入 curl 文件夹:(此文件夹可能因下载的版本不同而不同)

cd curl-7.47.0/

libcurl-openssl在运行下一部分之前,您可能需要重新安装库:

sudo apt install --reinstall libcurl4-openssl-dev

然后运行configure命令:

curl-7.47.0$ CPPFLAGS=-I/usr/local/include
curl-7.47.0$ LDFLAGS="-L/usr/local/lib -Wl,-rpath,/usr/local/lib"
curl-7.47.0$ LIBS="-ldl"
curl-7.47.0$ ./configure --disable-shared

然后运行makemake install命令:

curl-7.47.0$ make
curl-7.47.0$ sudo make install

然后 curl 应该会显示sftp协议:

curl-7.47.0$ curl -V
curl 7.47.0 (x86_64-pc-linux-gnu) libcurl/7.47.0 OpenSSL/1.0.2g zlib/1.2.8 libidn/1.32 libssh2/1.5.0
Protocols: dict file ftp ftps gopher http https imap imaps pop3 pop3s rtsp scp sftp smb smbs smtp smtps telnet tftp 
Features: IDN IPv6 Largefile NTLM NTLM_WB SSL libz TLS-SRP UnixSockets 

希望这可以帮助!

相关内容