KaliLinux 2017.1: 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.

#!/bin/shset -e[ -z “${WEBDAV_USERNAME}” ] && WEBDAV_USERNAME=webdav[ -z “${WEBDAV_PASSWORD}” ] && WEBDAV_PASSWORD=webdavsudo apt install -y apache2sudo systemctl enable apache2cat <<EOF | sudo tee /etc/apache2/sites-available/webdav.confAlias /webdav /var/www/webdav<VirtualHost _default_:443> SSLEngine on SSLCertificateFile /etc/ssl/certs/ssl-cert-snakeoil.pem SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key</VirtualHost><Location /webdav> DAV On SSLRequireSSL AuthType Digest AuthName webdav AuthUserFile /etc/apache2/.webdav Require valid-user</Location>EOFsudo mkdir /var/www/webdavsudo chown www-data:www-data /var/www/webdavfor mod in dav dav_fs dav_lock ssl auth_digest; do sudo a2enmod ${mod}donesudo a2ensite webdavsudo systemctl restart apache2yes “${WEBDAV_PASSWORD}” | sudo htdigest -c /etc/apache2/.webdav webdav ${WEBDAV_USERNAME}

2 Access to WebDAV

Install davfs2 package for mounting davfs.

$ sudo apt install -y 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:/sbin/mount.davfs: the server certificate does not match the server name issuer: <server> subject: <server> identity: <server> fingerprint: 0f:12:e7:65:67:63:7a:a8:e5:54:14:69:dd:6f:b5:80:1c:01:9f:cdYou only should accept this certificate, if you canverify the fingerprint! The server might be fakedor 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.txthello

Android | Linux | SDL - Narrow Escape