git-ftp / git-ftp

Uses Git to upload only changed files to FTP servers.
https://git-ftp.github.io/
GNU General Public License v3.0
5.47k stars 689 forks source link

Protocol 'sftp' not supported by curl #452

Open bedus-creation opened 6 years ago

JoshuaCrewe commented 6 years ago

Is there any more information you can provide with this issue?

Curl is able to use the sftp protocol. If you are on a mac with homebrew there is a flag to compile curl with libssh2 which gives support for sftp.

Although I am using the curl installed with OSX which says that it doesn't have support for sftp but this has not been a problem for me.

What are you having trouble with ?

> brew info curl

curl: stable 7.60.0 (bottled), HEAD [keg-only]
Get a file from an HTTP, HTTPS or FTP server
https://curl.haxx.se/
/usr/local/Cellar/curl/7.60.0 (423 files, 3.3MB)
  Built from source on 2018-06-06 at 11:26:25 with: --with-libssh2
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/curl.rb
==> Dependencies
Build: pkg-config ✔
Optional: openssl ✔, rtmpdump ✘, libssh2 ✔, c-ares ✘, libmetalink ✘, nghttp2 ✘
==> Options
--with-c-ares
        Build with C-Ares async DNS support
--with-gssapi
        Build with GSSAPI/Kerberos authentication support.
--with-libmetalink
        Build with libmetalink support.
--with-libssh2
        Build with scp and sftp support
--with-nghttp2
        Build with HTTP/2 support (requires OpenSSL)
--with-openssl
        Build with OpenSSL instead of Secure Transport
--with-rtmpdump
        Build with RTMP support
--HEAD
        Install HEAD version
==> Caveats
This formula is keg-only, which means it was not symlinked into /usr/local,
because macOS already provides this software and installing another version in
parallel can cause all kinds of trouble.

If you need to have this software first in your PATH run:
  echo 'export PATH="/usr/local/opt/curl/bin:$PATH"' >> ~/.zshrc

For compilers to find this software you may need to set:
    LDFLAGS:  -L/usr/local/opt/curl/lib
    CPPFLAGS: -I/usr/local/opt/curl/include
For pkg-config to find this software you may need to set:
    PKG_CONFIG_PATH: /usr/local/opt/curl/lib/pkgconfig
bedus-creation commented 6 years ago

I am on linux how can I compile with --with-libssh2 I tried with

JoshuaCrewe commented 6 years ago

Yes, hmmmm. I am not an expert with Linux I am afraid. I have mostly used Arch which has always had the latest packages with the most flexibility.

In theory it is as you say. Download the source for libssh2 and compile, download the source for curl and compile with the flag --with-libssh2. I had a bit of a go in a virtual machine to see how straightforward it would be. I couldn't get libssh installed in a place which could be found when compiling curl. You might have better luck with it though.

But as I say, I don't use curl with sftp support so maybe you don't need it either ? What are you trying to do that's not working as expected ?

mkllnk commented 6 years ago

The problem is that Ubuntu ships a version of curl that doesn't support SFTP. bug report. The only solution I could find, like you, is to compile it yourself. There are a few more tutorials:

rraallvv commented 5 years ago

I was able to use a self generated certificate like so:

openssl req -x509 -sha256 -nodes -days 365 -newkey rsa:2048 -keyout ~/.ssh/vsftpd.key -out ~/.ssh/vsftpd.crt
curl -T file-to-upload -v --ftp-ssl --cacert ~/.ssh/vsftpd.crt --user myuser:password ftp://SERVER-IP/file-to-upload

I had to upload the certificate files vsftpd.key and vsftpd.crt to add them to /etc/vsftpd.conf since I'm using vsftp

The problem I'm facing now is that git-ftp doesn't recognize --ftp-ssl although that parameter is needed with curl as shown in the command above after generating the certificate.

LukasFritzeDev commented 5 years ago

@bedus-creation Have you solved the problem?

peter279k commented 4 years ago

The problem is that Ubuntu ships a version of curl that doesn't support SFTP. bug report. The only solution I could find, like you, is to compile it yourself. There are a few more tutorials:

* http://zeroset.mnim.org/2013/03/14/sftp-support-for-curl-in-ubuntu-12-10-quantal-quetzal-and-later/

* http://andrewberls.com/blog/post/adding-sftp-support-to-curl

By default, the cURL command is disabled for SFTP protocol support on Ubuntu.

To have the cURL command with SFTP support on Ubuntu distribution, it should fetch cURL source codes and recompile them.

Here is the Gist link for help someone to recompile cURL package source on Ubuntu easily :).

All of files are tested well on Ubuntu 18.04.

This Gist link includes following files:

BTW, the cURL command is enabled for SFTP support on CentOS/RedHat distributions.

To verify cURL command is enabled for SFTP support, it can run following command to accomplish this:

 curl -V | grep sftp

And the expected output will be:

Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtmp rtsp scp sftp smb smbs smtp smtps telnet tftp

Enjoy it :)!

VFDouglas commented 1 year ago

If you're using Git FTP to deploy an app using pipeline via SFTP, switching image from Ubuntu to Debian worked for me. Ex.: git ftp push -u $FTP_USERNAME -p $FTP_PASSWORD $FTP_HOST

P.S.: $FTP_HOST = "sftp://127.0.0.1/var/www/html"

jemshit commented 1 month ago

The problem is that Ubuntu ships a version of curl that doesn't support SFTP. bug report. The only solution I could find, like you, is to compile it yourself. There are a few more tutorials:

* http://zeroset.mnim.org/2013/03/14/sftp-support-for-curl-in-ubuntu-12-10-quantal-quetzal-and-later/

* http://andrewberls.com/blog/post/adding-sftp-support-to-curl

By default, the cURL command is disabled for SFTP protocol support on Ubuntu.

To have the cURL command with SFTP support on Ubuntu distribution, it should fetch cURL source codes and recompile them.

Here is the Gist link for help someone to recompile cURL package source on Ubuntu easily :).

All of files are tested well on Ubuntu 18.04.

This Gist link includes following files:

  • build_curl_sftp.sh file can use them directly on your Ubuntu operating system directly.
  • Dockerfile file can build a Docker image with cURL command enabled SFTP support and it can use cURL command without polluting original cURL command on host operating system.

BTW, the cURL command is enabled for SFTP support on CentOS/RedHat distributions.

To verify cURL command is enabled for SFTP support, it can run following command to accomplish this:

 curl -V | grep sftp

And the expected output will be:

Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtmp rtsp scp sftp smb smbs smtp smtps telnet tftp

Enjoy it :)!

Min ubuntu supported by github actions is 20.04, any updated version of this script?

EDIT: looks like installed curl version on ubuntu 24.04 (latest) has sftp support:

curl 8.5.0 libcurl/8.5.0 OpenSSL/3.0.13 zlib/1.3 brotli/1.1.0 zstd/1.5.5 libidn2/2.3.7 libpsl/0.21.2 (+libidn2/2.3.7) libssh/0.10.6/openssl/zlib nghttp2/1.59.0 librtmp/2.3 OpenLDAP/2.6.7
Release-Date: 2023-12-06, security patched: 8.5.0-2ubuntu10.1
Protocols: dict file ftp ftps gopher gophers http https imap imaps ldap ldaps mqtt pop3 pop3s rtmp rtsp scp sftp smb smbs smtp smtps telnet tftp
Features: alt-svc AsynchDNS brotli GSS-API HSTS HTTP2 HTTPS-proxy IDN IPv6 Kerberos Largefile libz NTLM PSL SPNEGO SSL threadsafe TLS-SRP UnixSockets zstd

Yet same error

peter279k commented 1 month ago

Since the Ubuntu 20.04 is released, the curl is supported for the sftp protocol.

And this issue will not be happened.