OpenSUSE Leap 15: Install WebDAV for file server

Table of Contents

1 Install WebDAV

  • This article uses default SSL/TLS certicication file for https. Please change your SSL/TLS certification file.
  • Use https or davs for SSL.
  • WEBDAV_USERNAME is username and WEBDAV_PASSWORD is password for digest authentication.
  • Compared with OpenSUSE Leap 42, server.crt and server.key generated by gensslcert have hostname prefix.

#!/bin/sh -e[ -z “${WEBDAV_USERNAME}” ] && WEBDAV_USERNAME=webdav[ -z “${WEBDAV_PASSWORD}” ] && WEBDAV_PASSWORD=webdavsudo zypper -n in apache2sudo gensslcertcat <<EOF | sudo tee /etc/apache2/conf.d/webdav.confAlias /webdav /srv/www/webdavDAVLockDB /var/lib/webdav/DAVLock<VirtualHost _default_:443> SSLEngine on SSLCertificateFile /etc/apache2/ssl.crt/$(hostname -f)-server.crt SSLCertificateKeyFile /etc/apache2/ssl.key/$(hostname -f)-server.key</VirtualHost><Location /webdav> DAV On SSLRequireSSL AuthType Digest AuthName webdav AuthUserFile /etc/apache2/.webdav Require valid-user</Location>EOFsudo mkdir /srv/www/webdavsudo chown wwwrun:www /srv/www/webdavsudo mkdir /var/lib/webdavsudo chown wwwrun:www /var/lib/webdavsudo firewall-cmd –add-service=https –permanentsudo firewall-cmd –reloadsudo a2enflag SSLfor mod in ssl dav dav_fs auth_digest; do sudo a2enmod ${mod}donesudo systemctl enable apache2sudo systemctl restart apache2yes “${WEBDAV_PASSWORD}” | sudo htdigest -c /etc/apache2/.webdav webdav ${WEBDAV_USERNAME}

2 Access to WebDAV

Install davfs2 package for mounting davfs.

> O=> A=${O}/repositories/filesystems/openSUSE_Leap_15.0/> sudo zypper ar -f -n filesystems ${A} filesystems> sudo zypper -n –gpg-auto-import-keys ref> sudo zypper -n in davfs2

Run “mount -t davfs”.

> sudo mount -t davfs https://localhost/webdav /mntPlease enter the username to authenticate with serverhttps://localhost/webdav or hit enter for none. Username: webdavPlease enter the password to authenticate user webdav with serverhttps://localhost/webdav or hit enter for none. Password:<snip>Accept certificate for this session? [y,N] y

Write file via WebDAV.

> echo hello | sudo tee /mnt/hello.txt

For updating written file immediately, unmount /mnt.

> sudo umount /mnt

Written file can be read in /var/www/webdav.

> sudo cat /var/www/webdav/hello.txthello

Android | Linux | SDL - Narrow Escape