WebDAV File Sharing Setup In Linux – davfs
WebDAV is Web-Based Distributed Authoring and Versioning, open standard can be used for sharing files over the network using http and https protocols. More flexible to access remote data as an online hard disk. WebDAV File sharing is completely secure because it requires credentials to access.
WebDAV File Sharing
mod_dav is an Apache native module which will be installed by default when you install httpd packages. User feel more flexible while accessing the WedDAV File sharing because do not required any extra tools to access.
# yum install http httpd -y; systemctl start httpd; systemctl enable httpd Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.
Create WebDAV directory and lock database for further configuration
# mkdir -p /etc/httpd/var/webdavlock /var/www/html/webdav # chown apache:apache /var/www/html/webdav /etc/httpd/var/webdavlock # chmod 770 /var/www/html/webdav
Add new configuration file for WebDAV as a Virtual host in HTTPD conf path /etc/httpd/conf.d/
# cat /etc/httpd/conf.d/webdav.conf DavLockDB "/etc/httpd/var/webdavlock" <VirtualHost *:80> ServerAdmin root@localhost DocumentRoot /var/www/html/webdav/ ErrorLog /var/log/httpd/error.log Alias /webdav /var/www/html/webdav <Directory /var/www/html/webdav> DAV On Options None AuthType Basic AuthName "webdav" AuthUserFile /etc/httpd/passwords Require valid-user </Directory> </VirtualHost>
Create user to authentication and access, WebDAV from remote client
# htpasswd -c /etc/httpd/passwords aravi New password: Re-type new password: Adding password for user aravi [root@TechArkit ~]# cat /etc/httpd/passwords aravi:$apr1$uigd2VKZ$Ke93cQXrc/CJmXVbVKYDB.
Install and mount WebDAV using davfs file system
Configure EPEL repository by installing yum install epel-release
# yum -y install davfs2 # rpm -qa |grep davfs davfs2-1.4.7-6.el7.x86_64
If you try with other than EPEL repository you may not find the package in repository
After successful installation of davfs2, add the user locks entry or UN-comment the existing config line
# echo "use_locks 0" >> /etc/davfs2/davfs2.conf # mkdir /mnt/webdavmount # mount -t davfs http://192.168.220.128/webdav /mnt/webdavmount/ Please enter the username to authenticate with server http://192.168.220.128/webdav or hit enter for none. Username: aravi Please enter the password to authenticate user aravi with server http://192.168.220.128/webdav or hit enter for none. Password: /sbin/mount.davfs: Warning: can't write entry into mtab, but will mount the file system anyway
After successful mount check the mount point
# df -h Filesystem Size Used Avail Use% Mounted on http://192.168.220.128/webdav 26G 13G 13G 50% /mnt/webdavmount
Access from Web Browser
Open web browser and type the URL of WebDAV http://Server-IP/webdav
That’s how you can simple access the file share using web browser
Accessing Via Command line Client cadaver
cadaver – A command-line WebDAV client for Unix. cadaver supports file upload, download, on-screen display, namespace operations (move and copy), collection creation and deletion, and locking operations. Its operation is similar to the standard BSD ftp(1) client and the Samba Project’s smbclient(1). A user familiar with these tools should be quite comfortable with cadaver. cadaver supports automatically logging in to servers requiring authentication via a .netrc file (similar to ftp(1) – see section “THE .netrc FILE” below).
# yum install cadaver # cadaver http://192.168.220.128/webdav Authentication required for webdav on server `192.168.220.128': Username: aravi Password: dav:/webdav/>
That’s it about. WebDAV file sharing and accessing from client.