4

I am trying to access my 'Onedrive for Business' storage from the Linux console, specifically a headless Ubuntu 16.04 server. The only officially supported method is the Windows sync application.

I want to use Onedrive as a remote filesystem to extend my local storage, rather than duplicating all files locally with a sync client.

'Onedrive for business' is really a variant of Sharepoint that will not accept a username and password over webdavs - there must already exist an authentication cookie for the webdavs client.

I have successfully mounted the remote storage as a webdavs folder in Windows 10 by adapting these instructions: https://www.imss.caltech.edu/content/mounting-onedrive-business-mapped-drive but it only works after logging in to our Onedrive website with Internet Explorer to create a cookie that is used by Windows Explorer.

On Linux can I can replicate this behavior by logging in to the Onedrive website in the Konqueror web browser and then using that cookie to connect to webdavs in the Konqueror file browser. This is better than nothing, but I really need console access. Unfortunately KioFuse appears to be long abandoned.

Other than Konqueror, is there any way to do this that will make the remote filesystem accessible to the Linux console? I have looked at davfs2, gvfs, and cadaver, but I can't find any documentation for using an existing cookie for authentication.

1 Answer 1

6

You can use davfs2 with the add_header configuration option to send a Cookie HTTP header. Add these two lines to /etc/davfs2/davfs2.conf:

[/mount/path]
add_header Cookie rtFa=<...>;FedAuth=<...>

where /mount/path is your mount path and rtFa and FedAuth are cookies you can find in HTTP requests send by the browser when you connect to OneDrive.

Make sure there are no spaces in the second argument of add_header.

You can then mount the drive from the command line:

/sbin/mount.davfs https://<name>.sharepoint.com/<...> /mount/path
3
  • If the share is mounted as user (I'd probably prefer that), it is ~/.davfs2/davfs2.conf rather than /etc/davfs2/davfs2.conf. Commented Mar 8, 2022 at 10:28
  • Is there any tool that would open the login dialog in a browser or webview and extract the cookie to make this user-friendly(sh)? Commented Mar 8, 2022 at 10:29
  • @JanHudec Maybe xdg-open https://sharepointsite, login and then reading the file where the browser stores cookies, for Chrome it's a SQLite file inside the user profile Commented Feb 15, 2023 at 8:48

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.