This article will describe installing WebDAV.
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.
#!/bin/sh set -e [ -z "${WEBDAV_USERNAME}" ] && \ WEBDAV_USERNAME=webdav [ -z "${WEBDAV_PASSWORD}" ] && \ WEBDAV_PASSWORD=webdav sudo zypper -n in apache2 sudo gensslcert cat <<EOF | sudo tee /etc/apache2/conf.d/webdav.conf Alias /webdav /srv/www/webdav DAVLockDB /var/lib/webdav/DAVLock <VirtualHost _default_:443> SSLEngine on SSLCertificateFile /etc/apache2/ssl.crt/server.crt SSLCertificateKeyFile /etc/apache2/ssl.key/server.key </VirtualHost> <Location /webdav> DAV On SSLRequireSSL AuthType Digest AuthName webdav AuthUserFile /etc/apache2/.webdav Require valid-user </Location> EOF sudo mkdir /srv/www/webdav sudo chown wwwrun:www /srv/www/webdav sudo mkdir /var/lib/webdav sudo chown wwwrun:www /var/lib/webdav for t in FW_CONFIGURATIONS_EXT FW_CONFIGURATIONS_DMZ FW_CONFIGURATIONS_INT; do sudo sed -e "s/^${t}=\"\(.*\)\"/${t}=\"\1 apache2-ssl\"/g" \ -i /etc/sysconfig/SuSEfirewall2 done sudo systemctl restart SuSEfirewall2 sudo a2enflag SSL for mod in ssl dav dav_fs auth_digest; do sudo a2enmod ${mod} done sudo systemctl enable apache2 sudo systemctl restart apache2 # Create digest password file with expect command. sudo zypper -n in expect expect -c " set timeout -1 spawn sudo htdigest -c /etc/apache2/.webdav webdav ${WEBDAV_USERNAME} expect \"New password: \" send \"${WEBDAV_PASSWORD}\n\" expect \"Re-type new password: \" send \"${WEBDAV_PASSWORD}\n\" expect eof "
2 Access to WebDAV
Install davfs2 package for mounting davfs.
> O=http://download.opensuse.org > A=${O}/repositories/filesystems/openSUSE_Leap_42.2/ > 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 /mnt Please enter the username to authenticate with server https://localhost/webdav or hit enter for none. Username: webdav Please enter the password to authenticate user webdav with server https://localhost/webdav or hit enter for none. Password: /sbin/mount.davfs: the server certificate does not match the server name /sbin/mount.davfs: the server certificate is not trusted issuer: CA, SUSE Linux Web Server, unknown, unknown, XY subject: web server, SUSE Linux Web Server, unknown, unknown, XY identity: opensuse-14.hiroom2.com fingerprint: cc:46:1a:43:3b:b2:ec:55:37:81:83:b6:61:54:91:46:23:67:e8:2f 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] 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.txt hello