Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Protocol 'sftp' not supported by curl #452

Open
bedus-creation opened this issue Jun 4, 2018 · 8 comments
Open

Protocol 'sftp' not supported by curl #452

bedus-creation opened this issue Jun 4, 2018 · 8 comments
Labels

Comments

@bedus-creation
Copy link

bedus-creation commented Jun 4, 2018

No description provided.

@JoshuaCrewe
Copy link
Collaborator

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
Copy link
Author

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

@JoshuaCrewe
Copy link
Collaborator

JoshuaCrewe commented Jun 8, 2018

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
Copy link
Member

mkllnk commented Jun 9, 2018

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
Copy link

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
Copy link
Collaborator

@bedus-creation Have you solved the problem?

@peter279k
Copy link

peter279k commented Jun 15, 2020

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 :)!

@VFDouglas
Copy link

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"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

7 participants