There might be times or reasons for requiring a shared location on an OwnCloud instance to be mounted via WebDav. The OwnCloud team has put a great synchronization client together for all platforms, but what if the client can’t be installed, or it isn’t an owned resource (computer)? This solution allows full access to the data without syncing the data locally and also allows full functionality (i.e. uploading multiple files all at once simply by dragging and dropping that you can’t get from the web interface.)
Background / Cause
WebDav can be a good alternative to accessing data when other options aren’t available and / or viable. Linux has the tools to leverage this type of access as well.
Begin by installing or making sure the davfs2 software is installed. Issue the following to install:
sudo apt-get install davfs2
Reconfigure davfs2 to allow access to normal users (select Yes when prompted):
sudo dpkg-reconfigure davfs2
Add the users you want to be able to mount the share to the davfs2 group:
sudo usermod -aG davfs2 <user>
where <user> is the username of the individual to be allowed to mount the share.
Create the mount point for accessing the files by creating a directory:
sudo mkdir /media/ownCloud
Mount the WebDav connected ownCloud account to the directory location created in the step above with the following command:
mount -t davfs https://<owncloudaddress.com>/owncloud/remote.php/webdav /media/ownCloud
(Note: The HTTPS which will encrypt the communication and any supplied credentials, HTTP can also be used, but steps should be taken to ensure credentials are not being sent in clear text)
The credentials can be automatically supplied by adding them to the following file: system wide /etc/davfs2/secrets, or individually using ~/.davfs2/secrets
Edit either of the files depending on need using the following:
sudo nano /etc/davfs2/secrets sudo nano ~/.davfs2/secrets
where nano can be any editor of choice. Another method is to use the echo command. This doesn’t require actually opening the file, but instead issuing the following command:
echo “https://<owncloudaddress.com>/owncloud/remote.php/webdav <username> <password>” >> /etc/davfs2/secrets
where the “<” and “>” are not included and username / password are the credentials required to authenticate to the account.
The following line needs to be added to /etc/fstab to “automatically” mount the ownCloud account.
https://<owncloudaddress.com>/owncloud/remote.php/webdav /media/ownCloud davfs _netdev,user,rw,noauto 0 0
The “noauto” switch will prevent the device from being mounted automatically. Manually clicking the the “ownCloud” icon in the nautilus window or issuing the following command will still be required to mount the account. Removing the “noauto” switch above will cause the account to be mounted at startup.
To manually mount the ownCloud location, issue the following command in a terminal window:
using a user that has the rights to mount identified by membership in the davfs2 group. Adding users to this group is explained above.
Manually Mounting the ownCloud location
If it is desirable to manually mount the ownCloud location, no further action is required.
Automatically Mounting the ownCloud location only for a specific user
If it is necessary to automatically mount the ownCloud location when a particular user logs in, add the [mount /media/ownCloud] command to the users .bashrc file located in the users home directory.
Automatically Mounting the ownCloud location
To automatically mount the location, remove the noauto switch from the fstab file as shown below:
https://<owncloudaddress.com>/owncloud/remote.php/webdav /media/ownCloud davfs _netdev,user,rw,
Known Issues / Troubleshooting
Problem: Resource temporarily unavailable
Solution: If you experience trouble when you create a file in the directory, edit /etc/davfs2/davfs2.conf and add the following line:
Problem: Certificate warnings
Solution: If a self-signed certificate is used, a warning will be displayed. If the risk of a man in the middle attack is acceptable, run this command instead:
echo "y" | mount ~/owncloud > /dev/null 2>&1
(Note: These instructions should work fine with previous releases of Ubuntu and also on Debian.)
This documentation was taken almost exclusively from the document above. Much of the content was copied almost directly. This is simply a duplication of that documentation.