I am new to SharePoint. I was trying to download and upload file using Perl script in a Linux machine but getting an "NTLM Authentication Error" while running the script.

I tried downloading the file using "wget" providing valid credentials through following command:

wget --user username --password passwd http://dest.sharepoint.com/Folder/file.txt

But got the error "401 Unauthorized". I am not able to identify the cause. The 401 error occurs when authentication is required and it is not provided whether it has failed or not. But in the above case username and password provided is correct, because I am able to browse to the file using GUI in the browser with the same credentials.

If any one has any idea about this please let me know.


5 Answers 5


I have also come across this issue. Added -k option to curl command such as:

curl -k --ntlm -u username:password -O http://dest.sharepoint.com/Folder/file.txt

This will do the job.


This depends on the configured authentication-method. I.e. your method of access needs to be the same.

wget IMHO supports basic, disgest and NTML authentication. SharePoint 2013 supports (out-of-the-box) windows (i.e. NTLM), forms-based, and SAML-based claims authentication..

If your SharePoint WebApplication is configured to use windows authentication, wget NTLM should work. As should the curl --ntlm-command.

If your SharePoint is configured for forms-based authentication, you'll need to fake a login, and pass a cookie in your download-request. Check this question for ideas on how to do this.

I have no idea, what you could do if the SharePoint is configured for SAML-based claims authentication.


Please use rclone

Download and install the latest one from https://rclone.org/downloads

First option: Use OneDrive to access SharePoint sites/personal folder. This option will help you to upload large files.

1.create rclone configurations using the rclone config command

2.Select New remote and give a name

3.Select cloud storage OneDrive

4.Leave client ID and secret as blank

5.Edit advanced config: n

6.Remote config: Use auto-config: y

7.Open the URL on the browser and give access to rclone

8.Select personal/shared site URL option

8a.Shared site URL option you have to give the site URL. ie; https://sharepoint.com/sites/SiteName

9.Select personal/Documents drive. Documents drive will show if you selected the shared site URL option in the 8th step

  1. Save config and quit

And the configuration file contents will be like the following. If you selected the Personal option drive type will be personal.

type = onedrive
token = 
drive_id = 
drive_type = documentLibrary

Second option: In this option, you can upload up to 2 GB-sized files.

1.create rclone configurations using rclone config command

2.Select New remote and give a name

3.Select cloud storage WebDAV

4.Give site URL, username and password

5.Save and quit

And the configuration file contents will be like the following. Password will be in an encrypted format.

vim /root/.config/rclone/rclone.conf

type = webdav
url = https://sharepoint.com/sites/SiteName/Documents
vendor = sharepoint
user = 
pass = 

Download a file from SharePoint.

rclone copy --ignore-times --ignore-size --verbose sharepoint:SourceFolder/file.txt DestFolder

  • Why configure as root?
    – creanion
    Commented Nov 9, 2021 at 10:33
  • You can use any user, but execute rclone command as that user otherwise configuration won't pick. Commented Nov 10, 2021 at 11:31

thy curl : curl --ntlm -u username:password -O http://dest.sharepoint.com/Folder/file.txt

  • not working 0 file downloaded
    – VED
    Commented Nov 19, 2014 at 6:15
  • works fine here. replace username with [email protected] format
    – Eric
    Commented Nov 20, 2014 at 7:29
  • @Eric I don't think this works. Check the contents of the file you downloaded is not an HTML error page, instead of the file you were expecting.
    – Nick Bull
    Commented Jul 15, 2016 at 11:18
  • @Nick i have a test again just now, it works here. i get the correct file from sharepoint 2010 document library, using curl from osx.
    – Eric
    Commented Jul 21, 2016 at 6:31

The easiest way I have found, is using Chrome's debugger tools.

In the network tab, you can 'catch' the request that is being done when you click download in SharePoint.

On this request, you can right-click, and copy as curl. This will copy the correct command (incl. the cookies/authentication headers) to your clipboard.

You can then past that command in your console and the file will download.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.