IT in Education

Accessing Nextcloud via WebDAV

nextcloudWebDAV stands for Distributed Authoring and Versioning, and it can be used with Nextcloud to make a Nextcloud folder available on a Linux server. This article describes the process of setting this up.

Application Password

If you are using MFA (and you should be) then you will need to create an application password before proceeding with this task.

  1. Log into Nextcloud with the user account that you want sync with.
  2. Click your Avatar > Settings.
  3. Select Security in the left pane.
  4. At the bottom of this screen, enter an App name (e.g. MyServer-WebDAV)
  5. Click the Create new app password button.

It will reveal an app password that you can use along with your username, for the steps that follow.

Install davfs2

davfs2 allows you to mount WebDAV shares just like any other remote filesystem. The following commands will install davfs2, add your user account to the davfs2 group, and create a folder that includes your personal configuration file. I recommend allowing unprivileged users to mount WebDAV, otherwise only root will be able to use it.

$ sudo apt install davfs2
$ sudo usermod -aG davfs2 linux_username
$ sudo mkdir ~/nextcloud
$ sudo mkdir ~/.davfs2
$ sudo cp /etc/davfs2/secrets ~/.davfs2/secrets
$ sudo chown -R linux_username:linux_username ~/.davfs2
$ chmod 600 ~/.davfs2/secrets

Note that I needed to log out of Ubuntu and log in again, before my user account would become a member of the davfs2 group.


Edit the secrets file and add the following line:

/home/steven/nextcloud username password

Note that the password is the App password that you created earlier, and the username is the Nextcloud user account.


Add the following line using the URL that's given in Files settings on your Files page in Nextcloud, to the /etc/fstab file. /home/linux_username/nextcloud davfs user,rw,auto 0 0

Now run the following command to mount the folder.

$ mount ~/nextcloud

If you don't appear to have the right permissions, make sure that you own the .davfs2 directory and its contents. Also run groups to confirm that you are a member of the davfs2 group.

Single directory

If you only want to sync with a single directory, add the directory after /files/steven/ in the fstab file.

Thanks for visiting,