Does Azure SFTP service support curl command?

Camel Beck 0 Reputation points
2024-05-23T02:57:42.6833333+00:00

I have tried to visit Azure SFTP with curl command, like this:

curl  account_name.username:password sftp://account_name.blob.core.windows.net/file.csv -o res.csv

however it returned such an error:

Failure establishing ssh session

So, i want to make sure whether Azure SFTP support curl command. Could any one answer this question? thanks.

Azure Blob Storage
Azure Blob Storage
An Azure service that stores unstructured data in the cloud as blobs.
2,938 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Anand Prakash Yadav 7,795 Reputation points Microsoft Vendor
    2024-05-23T12:01:08.43+00:00

    Hello Camel Beck,

    Thank you for posting your query here!

    Azure SFTP service is a cloud-based solution that allows you to transfer files securely over SSH File Transfer Protocol (SFTP). You can use any SFTP client to connect to the service, including curl command.

    curl is a command-line tool that can be used to send and receive files over various protocols, including SFTP. To use curl with Azure SFTP service, you need to provide the following information:

    · The URL of the Azure SFTP service endpoint, which has the format sftp:// @ -sftp.azurewebsites.net

    · The password or the SSH key for authentication

    · The local file path or the remote file path for the file transfer

    Here are some examples of using curl with Azure SFTP service:

    You can also make use of the curl command to upload to the Azure Storage Account from Linux.  We need to follow the below command for the upload operation.
    curl -u "<Account Name>.<Local User Name>:<SSH-Key>" -k "sftp://<Account Name>-sftp.azurewebsites.net/test.txt" -o test.txt

    Here, parameter “T” stands for the file path on your local machine that you want to upload to the storage account. Adding the correct parameter, the above commands become as:

    curl -T /home/shxxx/sample.yaml -u "<Account Name>.<Local User Name>:<SSH-Key> " -k "sftp:/<Account Name>.blob.core.windows.net/~/sample.yaml"

    Below is an example of using curl to download a file named test.txt from the root directory of the Azure SFTP service to the current directory:

    curl -u "<Account Name>.<Local User Name>:<SSH-Key>" -k "sftp://<Account Name>-sftp.azurewebsites.net/test.txt" -o test.txt

    Similar issue: https://github.com/curl/curl/issues/4041

    Further reference: https://curl.se/docs/

    Do let us know if you have any further queries. I’m happy to assist you further.

    Please do not forget to "Accept the answer” and “up-vote” wherever the information provided helps you, this can be beneficial to other community members.


  2. Amrinder Singh 5,155 Reputation points Microsoft Employee
    2024-05-24T11:07:12.74+00:00

    Hi Camel Beck - Thanks for reaching out.

    I could repro the issue initially however I tried the below and it worked for me successfully.

    Can you try the below command:

    curl.exe -T "<Local Path of file to be uploaded>" -u "<AccountName>.<Username>:<Password>" sftp://<Account Name>.blob.core.windows.net/~/<FileName>

    Hope this answer helps! Please let us know if you have any further queries. I’m happy to assist you further.


    Please "Accept the answer” and “up-vote” wherever the information provided helps you, this can be beneficial to other community members.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.