cURL with SFTP via port 22 command line not supported/enabled

1

I'm struggling coming up with the right command to connect to a secure FTP server via port 22. When I'm connecting via Filezilla it works with username/pwd and port. After several attempts I ended up with this command that does not throw a port or command format error:

If I do curl -u <myuername>:<pwd> "sftp://datafeeds.shareasale.com:22/54291/54291.txt" -o "c:/temp/54291.csv" I get error curl: (1) Protocol "sftp" not supported or disabled in libcurl. I installed the latest binary from here: https://bintray.com/artifact/download/vszakats/generic/curl-7.60.0-win32-mingw.zip
But still it throws the same error, How can I add support/enable the SFTP protocol?

I already checked here: https://curl.haxx.se/mail/archive-2007-02/0070.html, https://curl.haxx.se/docs/manpage.html

Flo

Posted 2018-05-24T12:49:03.880

Reputation: 1 198

Answers

1

How can I add support for/enable the SFTP protocol?

It is already enabled (at least with the curl.exe binary you linked to). If you run curl -V in the bin directory of your extracted zip file, you will see that sftp support is one of the build options included in the version banner.

VZ Curl Build ScreenShot

I get an error - curl: (1) Protocol "sftp" not supported or disabled in libcurl.

As is, it's difficult to say exactly what the real issue might be, but one of three possibilities seems likely:

  • You are not actually using the version of curl you think you are. I would do curl -V from e.g. your desktop and see if sftp support was still listed in the banner. I would also do where curl to get a better idea of which curl.exe files are registered in your environment paths.

  • You may have a spelling error (e.g. " sftp" where there is an unintentional space before "sftp") or another problem with the URL you are accessing.

  • There is an issue with the server or its configuration.

Regarding general troubleshooting, I would run your curl command from the bin folder of your unzipped file. This way, there should be no issues with paths.

Finally, as a small note, the :22 is likely unnecessary — sftp runs on port 22 by default. The only reason to specify a port in this case is if the connection isn't going to be on port 22. That said, I would double-check the server port regardless (i.e. make certain is isn't using port 23 or 24, for example).

Anaksunaman

Posted 2018-05-24T12:49:03.880

Reputation: 9 278

Thanks! It's an issue with the path apparently that causes it to use an old version. Any idea how I can ensure a new version of curl is used without having to execute from that new directory? I don't see the old version that is being used in the path environment variable. – Flo – 2018-05-25T11:45:30.237

Creating an entry for the folder containing the new version of curl in your User PATH/System Path variables should be enough to overcome this, so long as that entry comes before any older one. So basically, create any new entry as the first entry in the list. In Windows 7, you can just edit it into the beginning of the variable (don't forget to separate entries with a semi-colon) and in Windows 10, you can move new entries to the top of the given environment variable list (with Move Up or Move Down). I would suggest rebooting afterwards to ensure Windows reloads the variables correctly. – Anaksunaman – 2018-05-25T12:27:14.843

1If editing your variables isn't an option, you could also create a batch file that runs your basic curl command with a full path to the new version of curl.exe and uses input from the command line when the batch file is run for specific things such as address links and output path. – Anaksunaman – 2018-05-25T12:36:30.763