Simple enough question, easy answer?
OneDrive for Linux. You’ve probably no doubt heard Microsoft whitter on about how much they love Linux and Open Source recently, but what about the use of their flagship products and their associated technologies? Microsoft Office has arguably got to be the most popular consumer application that Microsoft provide, and if you have used Office (or Office365) recently, you’ll see that saving your files to your PC is no longer the default option. In fact, in my opinion, its downright obfuscated. Instead, saving to their take of DropBox or Google Drive; Microsoft OneDrive is the default.
If you are ‘forced’ to use Microsoft products at work, there’s a good chance that they might be forcing you to save files into the cloud too. This is life, we can’t all be software freedom supremes!
So, the question is firstly, have Microsoft released an official OneDrive client for Linux? Put simply. No.
You had One job and now my Drive screwed it up….
Fear not! There are many ways to solve the conundrum, which might actually work out pretty well for you!
Here’s a few options for you, we will go into each of them in turn:
Name | Website | More information | OneDrive for Business/365 Support? |
OneDrive Official website | onedrive.live.com | Of course, you can always upload and download files via the official Microsoft OneDrive website. Yawn! | Yes |
Rclone for OneDrive | rclone.org/onedrive | A command line client that synchronises OneDrive and other cloud storage services | No |
DAVFS2 via WebDAV Protocol | savannah.nongnu.org/projects/davfs2 | WebDAV is a file transfer protocol using HTTP, OneDrive uses WebDAV under the hood | Not natively |
OneDrive free client | github.com/skilion/onedrive, and abraun’s new fork of this client |
A reliable, free CLI client. Includes state caching, Real-Time file monitoring with Inotify, Resumable uploads and Support OneDrive for Business (part of Office 365).
The new fork from abraunegg resolves some issues that people had recently (thanks philnc!) |
Yes |
onedrived-old and onedrived-dev | github.com/xybu/onedrive-d-old and github.com/xybu/onedrived-dev | CLI client which offers two way sync. The new client is written in Python3 and is being actively developed. | No |
GNOME 3 Desktop | http://www.gnome.org | The native GNOME desktop has built in support via the ‘Online Accounts’ feature to have read only access to your OneDrive | No |
KDE Desktop | www.kde.org | The KDE desktop uses the Konqueror file browser, which also has a built in HTTP/web browser capability. This allows you to browse files and authenticate properly | Quite likely, via the Konqueror web page interface |
SPFileZilla (mod) | github.com/suoko/spfilezilla | Written in Mono (open source .NET), it allows the user to access Sharepoint Online/OneDrive for Business clients via GUI that looks and operates just like the popular FileZilla FTP app. | Yes |
So, as you can see, you are spoiled for choice, but lets be clear here, if you are using OneDrive for Business (i.e., not the personal account that you sign up for online, but the business one that is managed by your company’s IT department on behalf of the users), then you are going to want OneDrive for Business/Sharepoint support. This immediately restricts you to either using the OneDrive website, or the OneDrive Free CLI client. I have heard that the KDE Konqueror file manager can also do this, however I have not tested it. Finally, there is the SPFileZilla, a modified version of the Windows version of an app with the same name. Effectively it is the Windows EXE file running on your desktop via Mono. Note that it works just like FileZilla, in that it behaves like a FTP client, upload and download – no file sync capability. The only client that offers two way sync is onedriveFree. In fact, the only feature that OneDriveFree does not currently support is Shared Folders, which can be a bit of a drag!
WebDAV
There really is no great way to use OneDrive for Linux. There are plenty of ways, however.
If you have OneDrive Personal, using DAVFS2 might be the cleanest option. You will see it using your file manager straight away and it will act pretty much like a normal network drive. Firstly, find out what your HTTPS WebDAV address should be (found HERE). You can either add an entry to your /etc/fstab (so that it is mounted on startup every time – recommended), or you can use GNOME Nautilus/Files (or KDE Konqueror) to mount it.
WebDAV is simply an HTTP file sharing protocol. Linux has strong support for it.
If you are using fstab, here is the sort of entry that you would use:
https://cid-blablabla.users.storage.live.com/items/blablabla /home/media/MS davfs user,noauto,file_mode=600,dir_mode=700 0 1
Make sure davfs2 is instaled on your machine before you do this obviously!
CLI based option
From the above table, clearly OneDrive Free is the leading client, supporting sync and OneDrive for business. Obviously you can still see the files it has downloaded in your normal file browser, however I can’t be 100% sure if this doesn’t cause any issues with file synchronisation. I’m pretty sure it won’t, but never say never!
Installation of OneDrive free requires you install a few things first (instructions for Debian/Ubuntu):
sudo apt-get install libcurl4-openssl-dev curl git
(this number will vary depending upon the version of dmd, note the output of the dmd build command)
sudo apt-get install libsqlite3-dev
curl -fsS https://dlang.org/install.sh | bash -s dmd
source ~/dlang/dmd-2.076.0/activate
git clone https://github.com/skilion/onedrive.git
cd onedrive
make
sudo -s
source ~/dlang/dmd-2.076.0/activate
make install
exit
Then simply start the tool by entering the word ‘onedrive -m &’ at the prompt (note the space after the -m – the & puts the program in the background). You’ll be given a URL to enter into your web browser. Enter this, log into OneDrive and you’ll end up on a blank page. Copy the URL of your browser back into the terminal, where it will be waiting for the URL. Once you enter it, a new folder in your home folder called ‘OneDrive’ will be made. It will start synchronising all of your OneDrive files.
Note that onedrive -m puts the tool into ‘monitor’ mode so that it can monitor for changes. Therefore, it runs permanently. Ideally you should run this in an init script or similar on startup, so you don’t have to run it from the terminal every time you start up your PC.
GUI (Graphical) Native options
On testing GNOME3’s latest ability to use OneDrive, I’d say its a bit of a joke. Read only file access is almost near useless. Konqueror should be able to accept your OneDrive token and start working like a normal file share – please post a comment if you get it working! However, if you are not a KDE user, like me, then this is a moot point! SPFileZilla is also an option, but it doesn’t support sync and its pretty ugly, considering you are really just using a Windows client! There is always the web browser with the OneDrive website, but again this is simple upload/download, no sync option.
Conclusion
Due to its maturity as a protocol and support under Linux, you can also choose to use WebDAV, but only if you are using OneDrive Personal.
Overall, however despite it being natively a CLI option, OneDrive FREE is the most feature rich, and once in monitor mode. Also, don’t forget that you can see all the files in your preferred GUI based file browser, such as Nautilus/GNOME Files etc. Have a look at the screenshot here:
I’ve tried setting up Onedrive access (Mint 18.3, Cinnamon 64 bit) on fstab with webdav and I am unable to make it work.
Based on your Microsoft link, it seems I should be using an fstab entry of the following form:
https://d.docs.live.net/blablabla/ /MountPointPath/myMountPoint davfs user,noauto,file_mode=600,dir_mode=700 0 1
Where “blablabla” is my cid as per what the MS link indicates.
When I tried that, I got a file manager entry on my sidebar corresponding to my mount point but when I clicked the entry I got a dialog informing me that it was “Unable to mount myMountPoint”.
I guessed it might be an authentication issue and found that I may need to insert authentication information into ~/.davfs2/secrets . I modified the file accordingly. Now I get a dialog informing me that it was “Unable to mount myMountPoint” but it also funnels through command line output: “/sbin/mount.davfs: Mounting failed.
302 Found”.
Indeed, if I simply run the mount command as “sudo mount -t davfs https://d.docs.live.net/blablabla/ /MountPointPath/myMountPoint”, I get a response asking for a user name and password but then the mount fails giving me the previous message:
sudo mount -t davfs https://d.docs.live.net/blablabla/ /MountPointPath/myMountPoint
Please enter the username to authenticate with server
https://d.docs.live.net/blablabla/ or hit enter for none.
Username: myUserName
Please enter the password to authenticate user myUserName with server
https://d.docs.live.net/blablabla/ or hit enter for none.
Password:
/sbin/mount.davfs: Mounting failed.
302 Found
Is this an impossible task or am I missing something very fundamental here?
Could be a few things- ensure permissions on the folder are ok, perhaps to test, consider putting your credentials in a text file and having the fstab read them from there. Also might be an SSL issue
I really think this is an authentication issue. I turned on debug with the httpauth option in the dav2fs.conf file and I am having syslog show “X-ClientErrorCode: AuthenticationFailed”. I do not know what to do to fix it, though.
i just try ” SPFileZilla ” and it works at first try !
just follow the indications from the Git project
Just a heads up: With your CLI-based option the input of the url returned by onedrive gave me quite a headache.
The solution seemed to be to remove the “&” from “onedrive -m&”… Just in case anybody else stumbles across this problem.
Thank you for your guide, it was very helpful!
Hi – note that there is a space between the -m and the &. The & puts the application into the background, allowing you to continue with other tasks at the CLI.
The first time you run the script, you can’t run it in the background or it loses focus and can’t accept the URI (bash takes over and has no idea what that URI means). After that first time, you can safely run it in the background as it won’t ask for that any longer.
Yes, second this. To set up I needed to leave off the ‘ &’ so that I could paste in the URL.
Thank you, by the way, Alistair, for a very nice article with a well-laid out table. I really appreciate it.
Sincerely, thank you! Always nice to get feedback!
I am on Ubuntu 17.10 and it doesn’t seem to work for me. I don’t get it. I have successfully logged in with my Microsoft account, However, there does not appear to be any onedrive folder in the home directory. What could I be doing wrong?
I’m using Manjaro linux and I’m looking for a way to access my OneDrive. I tried to install OneDrive Free but I was getting a warning message that says “unsupported package.. potentially dangerous!”a
That’s just a paranoid (ish) warning – ignore and install, I have, it works for me.
Thank you for your guide. Very helpful!
However, it stopped to syncronise. I used the CLI-based option. I managed to syncronise two folders downloading from the web and uploading from the computer.
Then, I added a third folder to upload and from the shell there is not sign of syncronisation and the new files do not appear on the web version of OneDrive.
I tried onedrive -m but I get an error because it tries to create a folder that already exists.
Can you help me?
Hi there,
Newbie here! I added my Microsoft account to Ubuntu’s Online Accounts. I switched the Documents switch to ON (default). I read that I can now read my OneDrive files. My question is: how do I do that? I expected OneDrive to show up as a file location in the Files app. But that didn’t happen.
Do I need an additional app (I read a lot about onedrive)? And if so, what is than the advantage of the Online Accounts?
Thanks for any clarification.
So a couple of updates: (1) the free onedrive client from skilion can be installed as a (quite reliable) systemd service (as your user); (2) skilion’s code has been forked by abruanegg (https://github.com/abraunegg/onedrive) on github and that code does resolve some problems people have had recently; (3) Gnome File’s integration with OneDrive has been hopelessly broken almost from the beginning, it also _never_ worked with accounts that have MFA enabled (ditto for Google Drive integration). Pro tip when building onedrive: pay close attention to the README.md and be sure to check out the Issues tab.
This is some great piece of information. What are your thoughts on using a VPN such as Ivacy with Linux? I know Linux has better security than any other OS, is a VPN really needed for better security?
Yes, I still recommend using a VPN for surfing the web to enhance security.