16

We have started using SharePoint Online included with our Office 365 subscription. Our windows users can install software that automatically syncs the Shared Documents from SharePoint to their Windows computers. How do I enable my Linux (Ubuntu) users to do the same?

I thought WebDav would work, but my attempts always fail, mostly with "HTTP Error: FORBIDDEN". Specifically, I try to add a server via Nautilus file browse and fail:

Server: mycompany.sharepoint.com
Port: 443
Tppe: Secure WebDav (HTTPS)
Folder: /
User name: [email protected]
Password: ********

HTTP Error: FORBIDDEN

I have tried changing User Name to:

 mycompany\first.last

I have tried changing folder to:

 /Shared%20Documents

and various other paths based on web searches to no avail.

Should this work? Is there a better solution?

2
  • 2
    Did you ever find a solution? I have a similar problem. Dec 10, 2015 at 18:57
  • Unfortunately no (though I haven't checked recently to see if MS changed anything). We also have BOX.COM which does support WebDav and have mostly switched to that...thereby wasting all our SharePoint storage. :(
    – proximous
    Dec 11, 2015 at 1:30

5 Answers 5

9

This works with the latest version of rclone which is 1.50 at the moment:

https://rclone.org/downloads/

OneDrive for Business is basically sharepoint, it works by the rclone setup as described here:

https://rclone.org/onedrive/ (check the limitations!)

So basically you run in a terminal:

rclone config

Then type n, then type a name and choose option 22 after (this may change, but the onedrive option is meant here). Then hit enter twice (client id and secret are not needed) and then n for no advanced config. Then enter y for autoconfig (your browser should open and it's convenient if you're logged in, it will redirect and show a succes message in the browser.

Go back to the terminal and choose 1 for onedrive. This should show you a drive, choose 0. Next message, choose y to confirm, the next y too.

Now you have the config setup, so you can mount the share as:

rclone --vfs-cache-mode writes mount onedrive: ~/OneDrive

where onedrive is the name of the share you created and ~/OneDrive is the folder in your home directory where you mount it.

If something goes wrong with mounting, you can umount with:

fusermount -uz ~/OneDrive/

You may have noticed that shared folders are not there. It's not supported in rclone at the moment for the business version. To work around that, you can use WebDAV config to mount it. More on that can be found here:

https://rclone.org/webdav/

for vendor choose sharepoint so your config looks something like:

[onedriveShared]
type = webdav
url = https://domain.sharepoint.com/personal/firstname_lastname_domain_com/Documents
vendor = sharepoint
user = [email protected]
pass = encryptes_pass

The issue here is that you would need to add this for every share. Unfortunately Microsoft didn't deem it necessary to support Linux so my advice is and was to stay away from their products and use the ones that work out of the box.

Update: the mentioned gist is this, I haven't tested it but added it here for convenience and completeness, it should handles shares :

# User service for Rclone mounting
#
# Place in ~/.config/systemd/user/
# File must include the '@' (ex [email protected])
# As your normal user, run 
#   systemctl --user daemon-reload
# You can now start/enable each remote by using rclone@<remote>
#   systemctl --user enable --now rclone@dropbox

[Unit]
Description=rclone: Remote FUSE filesystem for cloud storage config %i
Documentation=man:rclone(1)
After=network-online.target
Wants=network-online.target 

[Service]
Type=notify
ExecStartPre=-/usr/bin/mkdir -p %h/mnt/%i
ExecStart= \
  /usr/bin/rclone mount \
    --config=%h/.config/rclone/rclone.conf \
    --vfs-cache-mode writes \
    --vfs-cache-max-size 100M \
    --log-level INFO \
    --log-file /tmp/rclone-%i.log \
    --umask 022 \
    --allow-other \
    %i: %h/mnt/%i
ExecStop=/bin/fusermount -u %h/mnt/%i

[Install]
WantedBy=default.target
2
  • 1
    RClone mounting Sharepoint with WebDav worked out great for me. To get the URL for a shared root directory (instead of your personal space), you just have open a shared folder and look at the URL to find what listurl is equal to. To make mounting more convienent, this gist shows how to create a systemctl service that supports multiple remotes. Jan 23, 2021 at 4:14
  • 1
    @ChrisHayes you should throw that GIST up here in the response since I think that's useful and relevant to the response ;) Apr 27, 2022 at 14:33
7

Connecting to Office365 Sharepoint (or 'OneDrive for Business') by WebDAV requires an existing authentication cookie. You can't log in with a username and password in your WebDAV client. On Windows you can achieve this by adding the Sharepoint site to Internet Explorer's list of Intranet Sites and then logging in with Internet Explorer and ticking 'Keep me logged in', then it will let you map the network drive in Windows Explorer.

The only way I have found to do this on Linux is with Konqueror, because it contains both a web browser and a WebDAV-enabled file browser. You can log in to the Sharepoint site in the Konqueror browser, then the Konqueror file browser can use that cookie to authenticate to WebDAV.

3
  • 1
    Doesn't work for me, I'm getting error 111 (?) when trying to connect to webdavs://xxx.sharepoint.com/yyy/after successfully logging in with the web browser part of Konqueror.
    – nidi
    Mar 9, 2018 at 12:38
  • This does work for me: using konqueror to go to https://company.sharepoint.com/sites/personal and after logging in, opening webdavs://company.sharepoint.com/sites/personal in another konqueror window. The rclone method does not work for me: it opens a login page to get system administrator privileges. That is not realistic, so this is the most useful suggestion!
    – alle_meije
    Dec 7, 2022 at 10:23
  • Also see n-shah's answer for more information about the full path to enter in the webdavs:// URL. Jan 19, 2023 at 5:51
7

It is indeed possible, but I don't have a smooth solution yet. I'm mounting SharePoint Drives with davfs2. For this to work you have to authenticate with a browser (by simply accessing your SharePoint site). You then have to extract the Cookies named "rtFa" and "FedAuth". They have to be pasted at the end of the file /etc/davfs2/davfs2.conf like so:

add_header Cookie rtFa=<your cookie here>;FedAuth=<your other cookie here>;

Also add the following line:

use_locks 0

To mount the share, I use the URL of the SharePoint-Webinterface-URL of the Share, without the default.aspx at the end. I also entered them into /etc/fstab, so I can easily mount them:

https://myinstitution.sharepoint.com/sites/path/to/my/share/      /path/to/my/mountpoint   davfs   user,rw,noauto  0       0

To get the cookies to the davfs2.conf file, I use Chrome with the cookies.txt Extension, so I can save them to a file cookies.txt with two clicks. Then I wrote a small Ruby-Script which parses this file and adds the line to the davfs2.conf file. I currently have a sympolic link from /etc/davfs2/davfs2.conf to a file on my home directory, but the cleaner way of doing it would be a config file per user (which davfs2 allows afaik). It's far from ideal, but it does the job for now.

#!/usr/bin/ruby

davfsFile = "/path/to/the/file/davfs2.conf"  # Replace this
cookiesFile = "/path/to/the/file/cookies.txt"  # Replace this
cookies = File.read(cookiesFile).split("\n").map{|c| c.split("\t")}
`rm #{cookiesFile}`

cookies.select!{|c| c[5]=="rtFa" || c[5]=="FedAuth"}
cookieline = "add_header Cookie #{cookies[0][5]}=#{cookies[0][6]};#{cookies[1][5]}=#{cookies[1][6]};"

davfsconf = File.read(davfsFile).split("\n")
davfsconf[-1]=cookieline
File.write(davfsFile, davfsconf.join("\n"))

File transfer is fast and usable, directory access is almost unusably slow, something like ls */bla takes 40 s in a directory with 30 entries... I'm investigating the cause and I will post here when I know more...

2
  • I like your idea. I wonder if you solved directory browsing slowdown? Jun 19, 2021 at 3:24
  • I did not change anything, however Microsoft did improve their service (for instance we don't suffer downtime every monday after school breaks anymore). It is now rather usable this way. Jun 22, 2021 at 6:35
2

So I do recognize that this question is quite old, though I was searching for this today and could not find any good answers.

I found that what you want to do is go to "https://office.com" and click sign in, from here sign in with your office 365 account as normal Once you are signed in, click on onedrive, you should see a screen similar to this Screen with onedrive office 365 loaded

Once you see this screen, your sharepoint cookie is loaded. you'll see my URL is https://alicesworld-my.sharepoint.com/personal/alice_alicesworld_tech//_layouts/15/onedrive.aspx So what you want to do is REMOVE the last 3 paths in the URL, and add Documents/ like this: https://alicesworld-my.sharepoint.com/personal/alice_alicesworld_tech/Documents/ then change https:// to webdavs://

your final URL should be webdavs://XXXX.sharepoint.com/personal/XXX_XXX_XXX/Documents/

this URL will work in both Konqueror and Dolphin

Screenshot of webdavs onedrive working in konq

To add this folder as a network drive in Dolphin,

Go to the sidebar and click Network then at the top click "Add Network Folder" Click WebFolder (WebDav)

Here the Name can be anything you would like,

Keep the user Field blank

For servername, put the URL without the path,for me thats "alicesworld-my.sharepoint.com"

For folder, put the rest of the URL, for me thats "/personal/alice_alicesworld_tech/Documents/"

finally click the "Use Encryption" Checkmark

Your final result should look something like this Picture of KDE Network Wizard

After this unfortunately long process, everything should work as intended Picture of onedrive folder in dolphin

  • Note, to get dolphin to work, you still have to do the konqueror steps first, this is because you need the Authentication cookie for it to connect, and konqueror is what stores it
1
  • This worked great for me. Just a note: if the folder that is shared with you is not the root folder of the other user, you may need to enter the full path after Documents/, as sharepoint will claim that Documents alone does not exist. So do webdavs://XXX.sharepoint.com/personal/XXX/Documents/some path/to the files/ (spaces are fine) Jan 19, 2023 at 5:46
0

I confirm that konqueror does work. However as far as i was told spfilezilla connects to onedrive for business and sharepoint with an anonymous token. See here: https://github.com/suoko/spfilezilla If that's true we can make davfs create the anonymous token

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .