Nextcloud is a handy self hosted web-based application that can be used to store files, contacts and calendars.
It provides the desktop and mobile client.
In addition, it supports Web Distributed Authoring and Versioning protocol, so lets mount a WebDAV share.
Install required software
Install davfs2
package to mount WebDAV resource as regular file system.
$ sudo apt-get install davfs2
Mount WebDAV share using command-line
Create the mountpoint directory.
$ sudo mkdir /mnt/dav
Use mount
command to mount the WebDAV share.
$ sudo mount -t davfs -o noexec https://nextcloud.example.com/remote.php/webdav/ /mnt/dav/
Please enter the username to authenticate with server https://nextcloud.example.com/remote.php/webdav/ or hit enter for none. Username: milo Please enter the password to authenticate user milosz with server https://nextcloud.example.com/remote.php/webdav/ or hit enter for none. Password: /sbin/mount.davfs: warning: the server does not support lock
Use umount
command to unmount the WebDAV share.
$ sudo umount /mnt/dav /sbin/umount.davfs: waiting while mount.davfs (pid 1475) synchronizes the cache .. OK
Mount WebDAV share using fstab
Create fstab
entry to allow the specified user to mount the filesystem.
$ cat << EOF | sudo tee -a /etc/fstab # personal webdav https://nextcloud.example.com/remote.php/webdav/ /mnt/dav davfs _netdev,noauto,user,uid=milosz,gid=milosz 0 0 EOF
Store username and password for the remote WebDAV share.
$ cat << EOF | sudo tee -a /etc/davfs2/secrets # personal webdav, nextcloud application password /mnt/dav milosz mypassword # older versions used URL, it is equivalent for compatibility reasons #https://nextcloud.example.com/remote.php/webdav/ milosz mypassword EOF
You can mount the above-mentioned WebDAV share using sudo
utility.
$ sudo mount /mnt/dav
Additional notes
If you try to mount it as regular user and encounter the following error, then you need to set SUID
bit on the mount.davfs
binary.
$ mount /mnt/dav /sbin/mount.davfs: program is not setuid root
Execute dpkg-reconfigure
to reconfigure davfs2
package, set the SUID
bit and allow unprivileged users to mount WebDAV resources.
$ sudo dpkg-reconfigure davfs2
In addition, user must be a member of the davfs2
group.
$ mount /mnt/dav /sbin/mount.davfs: user milosz must be member of group davfs2
Use the following command to add specified user to required group.
$ sudo usermod -a -G davfs2 milosz