skip to main |
skip to sidebar
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 serverhttps://nextcloud.example.com/remote.php/webdav/ or hit enter for none. Username:
Please enter the password to authenticate user with serverhttps://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 webdavhttps://nextcloud.example.com/remote.php/webdav/ /mnt/dav davfs _netdev,noauto,user,uid=,gid= 0 0EOF
Store username and password for the remote WebDAV share.
$ cat << EOF | sudo tee -a /etc/davfs2/secrets# personal webdav, nextcloud application password/mnt/dav mypassword# older versions used URL, it is equivalent for compatibility reasons#https://nextcloud.example.com/remote.php/webdav/ mypasswordEOF
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
Reconfigure davfs2 package
In addition, user must be a member of the davfs2 group.
$ mount /mnt/dav/sbin/mount.davfs: user must be member of group davfs2
Use the following command to add specified user to required group.
$ sudo usermod -a -G davfs2