curl account_name.username:password sftp://account_name.blob.core.windows.net/file.csv -o res.csv
So, i want to make sure whether Azure SFTP support curl command. Could any one answer this question? thanks.
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.
Thanks very much for your answer.
I have executed the command in the same as what you provided above, but it still returned the same error "curl: (2) Failure establishing ssh session".
Do you think it has something with the version of curl or openSSH on my machine? The versions on my machine as below:
curl: 7.53.1 (x86_64-pc-linux-gnu) libcurl/7.53.1
openSSH: 7.4p1 Debian-10+deb9u7, OpenSSL 1.0.2u
By the way, I can log in the same sftp server with sftp command. FYI.
Hope to get your answer soon.
Hello
Camel Beck
,
It's possible that the issue is related to the version of curl or OpenSSH on your machine. However, since you're able to log in to the SFTP server using the sftp command, it suggests that SSH connectivity is working.
Ensure that the versions of curl and OpenSSH on your machine are compatible with each other and with the SFTP server's configuration. You may try to update either curl or OpenSSH to ensure compatibility.
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.