Ubuntu: Fix Protocol “sftp” not supported or disabled in libcurl

Make SFTP work with CURL

If you are facing this issue with cURL in an ubuntu server, try the following fix. Be cautious. And if you have a better solution or improvements, please let me know.

Steps to Fix Protocol “sftp” not supported or disabled in libcurl are as follows:

Step 1: Install needed dependencies

Install build-essential, libssl-dev

sudo su

apt install -y build-essential libssl-dev

That will install the necessary dependencies we need.

Step 2: Download and install libssh2

Go to the official libssh2 page and download the latest .tar.gz file.

cd /tmp

wget https://www.libssh2.org/download/libssh2-1.9.0.tar.gz

Change the URL to the latest version’s link. Once the download is done, unpack the tarball.

tar zxvf libssh2-1.9.0.tar.gz

Once the unpacking is done, cd libssh2-1.9.0 and run the following in sequence:

./configure
make
make install

If these succeed without any errors, you will now have libssh2 installed and ready to be used for configuring curl with it.

Step 3: Configure and install CURL

Similarly, download and unpack the latest version of curl from the official page.

cd /tmp
wget https://curl.haxx.se/download/curl-7.73.0.tar.gz
tar zxvf curl-7.73.0.tar.gz
cd curl-7.73.0
./configure --with-libssh2=/usr/local
make
make install

If you don’t see any errors, the latest version of curl is now installed in /usr/local/bin

Step 4: Solve any potential libcurl.so.4 issues

First, run this command and see if you are seeing any errors:

/usr/local/bin/curl -V

If you get an error message about libcurl.so.4, make a symbolic link like so:

 ln -s /usr/local/lib/libcurl.so.4 /lib/x86_64-linux-gnu/

then run /usr/local/bin/curl -V again and you will see no errors.

Step 5: make sure only one CURL version is being used

Move the old executable

mv /usr/bin/curl /usr/bin/curl_old

make sure the /usr/local/bin is included in the PATH

export PATH=/usr/local/bin:$PATH

Step 6: Verify that CURL is working

Exit the terminal and start SSH/terminal again.

Once done, type curl -V and you should see that SFTP is now working.

SFTP is now supported
SFTP is now supported

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.