Automating a mount operation that requires user input
Solution 1
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.
Solution 2
Wouldn't it just be easier to fix the trust issue and install the certificate?
-
Download the certificate (thanks to elec3647 on SuperUser)
openssl s_client -connect HOSTNAME:443 -showcerts </dev/null 2>/dev/null | openssl x509 -outform PEM > certificate.pem
-
Copy the certificate to
/etc/davfs2/certs/
sudo cp certificate.pem /etc/davfs2/certs/
That should deal with the problem directly.
Related videos on Youtube
Comments
-
jotrocken over 1 year
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.
-
jotrocken almost 10 yearsYou are right, this is the straight-forward way. Which fails because of
/sbin/mount.davfs: the server certificate does not match the server name
. This is why I need a workaround. Will edit this above. -
Donn Lee over 7 yearsThanks jotrocken, I was running davfs2 1.4.7 which doesn't support
trust_server_cert
. I might have to compile from the source code. Latest version is 1.5.4 at the time of this comment. -
dynamiclynk about 3 yearsThank you! Finally an example that worked.