0

I am trying to setup SFTP with cURL and I followed these instructions on Andrew Berls' blog, but if I run the command curl -V I get this output:

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

So for some reason sftp is not showing up, how can I fix this?

This is the error log when I run make install following the instructions above:

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 Answers1

1

On the link you provided, according to the very first comment curl needs to be installed from source with the --disabled-shared ran with the ./configure command:

First, get the curl source:

apt source curl

Then go to the curl folder: (this folder could be different depending on version downloaded)

cd curl-7.47.0/

You might need to reinstall the libcurl-openssl libraries before running the next part:

sudo apt install --reinstall libcurl4-openssl-dev

Then run the configure command:

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

Then run the make and make install commands:

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

Then curl should now show the sftp protocol:

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 

Hope this helps!

Terrance
  • 41,612
  • 7
  • 124
  • 183
  • I'm getting this error on running the make install command 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 – Harry Cameron Jan 14 '18 at 16:37
  • would I need to uninstall cURL before reinstalling it? – Harry Cameron Jan 14 '18 at 16:49
  • @HarryCameron I didn't have to uninstall first. I followed Step 1 on that site then Step 2, but the Step 2 made no difference. So from my source folder, I made the install clean make clean then I reran through the steps in my answer. – Terrance Jan 14 '18 at 16:51
  • even if I try the make clean command then I reran through the steps from your answer but got the same error – Harry Cameron Jan 14 '18 at 16:53
  • @HarryCameron Try running this before doing it: sudo apt install --reinstall libcurl4-openssl-dev – Terrance Jan 14 '18 at 16:54
  • I still get the same error, so I ran the above command, then make clean within the curl-7.47.0 folder, then I ran ./configure --disable-shared then make and the error popped up – Harry Cameron Jan 14 '18 at 16:59
  • @HarryCameron Looks like on this page https://github.com/curl/curl/issues/1583 that they were getting the same error. So, before the configure they typed in all 3 of these lines: CPPFLAGS=-I/usr/local/include \ , LDFLAGS="-L/usr/local/lib -Wl,-rpath,/usr/local/lib" \ , LIBS="-ldl" \ I can't get the editing here right. I will add those to the answer. – Terrance Jan 14 '18 at 17:04
  • I have updated the original post with the full log I get after running make install – Harry Cameron Jan 14 '18 at 17:26
  • @HarryCameron I am actually no longer of help here as I cannot duplicate your issue that you are having. Everything I have thrown your way I am googling to find from here on out. I will not be any help in chat. It doesn't sound like it is an issue with curl itself but more with the libraries and how they are installed. I am able to follow through those steps on two different computers and they have worked for me. – Terrance Jan 14 '18 at 17:55
  • I now have the SFTP protocol installed as it shows up when I run curl -V but I still cant upload files to my server using cURL – Harry Cameron Jan 17 '18 at 15:42
  • 2
    A few notes: I had to run apt-get install libssh2-1-dev. When I ran the configure command, I had to also use the --with-libssh2 option. Finally, after running make install, it places the curl file in /usr/local/bin. – Teddy Jan 03 '19 at 20:40
  • @Teddy Good find! It has been a while since I touched this, but that is awesome info for the newer version of curl. Just ran it and it worked perfectly! Thank you! =) – Terrance Jan 03 '19 at 21:09