Skip to main content

Davfs: mounting https webdav resource

 

Here is a simple guide to automaticaly mount a webdav resource in linux.  In this case we are going to use davfs2 to mount our webdav resource. Davfs is able to mount a WebDAV resource as a regular file system and access it in the same way as others directories in your system. In Ubuntu you have to install davfs2 package:


$ sudo apt-get install davfs2

Usually,   you access to your webdav resource with a username and password. In davfs you can do it automatically putting the username and password in  .davfs/secrets file in your home directory. Davfs gets this data and does login for you.

Here is an example of .davfs/secrets file,  “/home/user/webdav” is the mount point of your webdav resource:


/home/user/webdav username password

You can put this configuration in  /etc/fstab file:


https://myserver.org/webdav /home/user/webdav/ davfs user,noauto 0 0

Now,  you can see this new resource in nautilus file browser and you can mount it automatically.

If you are trying to mount a https resource you have another problem to deal with:   the server certificate. If server certificate you are using is sefsigned or from a CA cert that is not known for your system,   you are going to see these message when you are trying to mount the webdav resource:

You only should accept this certificate, if you can
verify the fingerprint! The server might be faked
or there might be a man-in-the-middle-attack.
Accept certificate for this session? [y,N]

You can’t accept the certificate permanently,  so you can’t mount the resource trough the fstab to be accesible from nautilus,  because davfs is going to be waiting until you enter the answer. What you have to do is configure the CA certificate in PEM format on davfs to always be trusted. To do that edit .davfs2/davfs2.conf in your home directory or /etc/davfs2.conf for system wide and insert this line:


servercert      ca-cert.pem

You have to put your CA cert file (ca-cert.pem) on .davfs/certs directory.
Now you can mount webdav resource from nautilus without problems.

 

One thought to “Davfs: mounting https webdav resource”

  1. How do I get the certificate? I mean, what if I trust the certificate, but don’t have the file?

Leave a Reply to The Joker Cancel reply

Your email address will not be published. Required fields are marked *

*

This site uses Akismet to reduce spam. Learn how your comment data is processed.