Ubuntu – Automating a mount operation that requires user input


I want to mount a directory on a file server at startup. This is my /etc/fstab entry:

# mount the fileserver
https://fsrv.company/ /mnt/fileserver davfs user,auto 0 0

Manually mounting it with mount /mnt/fileserver works fine. However, because of an outdated certificate this issues a prompt which I always have to answer with yes:

/sbin/mount.davfs: the server certificate does not match the server name
/sbin/mount.davfs: the server certificate is not trusted
Accept certificate for this session? [y,N] y

This device should be mounted when starting Ubuntu (due to the auto option). However, the device is not mounted, probably because of the required input. The owner of the fileserver wont update its certificate.

How can I automate this process, such that the device is mounted at startup with the answer being always y\n?

EDIT: I did download and place the certificate in .davfs2/certs/ and edited the entry in .davfs2/davfs2.conf (as hinted below by @Oli), but the interactive input remains.

Best Answer

  • In my case I used the code highlighted by Oli above and then used the trust_server_cert option in the dav2fs config.

    Usefull when the server's certificate can't be verified or is even invalid, but you know that you can trust this certificate.

    So edit /etc/davfs2/davfs2.conf and add a line that looks like the following:

    trust_server_cert        /etc/davfs2/certs/my.selfsigned.cert.pem

    This allowed me to mount a self-signed OwnCloud webdav even when the certificate host didn't match.