Techno Blog Just another Technology Blog

2Jan/120

Using davfs

Overview
davfs allows you to mount a WebDAV resource into the local filesystem. davfs runs as a daemon in userspace (FUSE).

Install davfs2

# apt-get install davfs2

Allow unprivileged users to mount WebDAV resources

# dpkg-reconfigure davfs2

Should unprivileged users be allowed to mount WebDAV resources? Yes

In this example I am using a WebDAV resource supplied by Swissdisk Swissdisk encrypts your data and claim that they are unable to decrypt it, however I assume that is a lie and encrypt is again using encfs.

Mount WebDAV Resource
Create mount point, mount resource, view and unmount.

# mkdir -m 755 /mnt/swissdisk

# mount.davfs https://disk.swissdisk.com/user/ /mnt/swissdisk
Please enter the username to authenticate with server
https://disk.swissdisk.com/user/ or hit enter for none.
  Username: user
Please enter the password to authenticate user user with server
https://disk.swissdisk.com/user/ or hit enter for none.
  Password:

# df -h /mnt/swissdisk
Filesystem            Size  Used Avail Use% Mounted on
https://disk.swissdisk.com/user/
                       26G   13G   13G  50% /mnt/swissdisk

# umount /mnt/swissdisk
/sbin/umount.davfs: waiting while mount.davfs (pid 6317) synchronizes the cache .. OK

davfs2 group
Add users to davfs2 group to allow them to WebDAV resources

# gpasswd -a username davfs2
Adding user username to group davfs2

fstab
In order for a normal user to be able to mount this, there needs to be an entry for it in /etc/fstab. Appending the following to /etc/fstab:

https://disk.swissdisk.com/user/    /mnt/swissdisk  davfs   user,rw,noauto  0       0

Mount as normal user

$ mount /mnt/swissdisk 
Please enter the username to authenticate with server
https://disk.swissdisk.com/user/ or hit enter for none.
  Username: user
Please enter the password to authenticate user user with server
https://disk.swissdisk.com/user/ or hit enter for none.
  Password:

$ df -h /mnt/swissdisk
Filesystem            Size  Used Avail Use% Mounted on
https://disk.swissdisk.com/user/
                       26G   13G   13G  50% /mnt/swissdisk

$ ls -al /mnt/swissdisk/
total 1060
drwxr-xr-x 3 username username    280 2011-03-06 18:08 .
-rw-r--r-- 1 username username    131 2010-12-11 17:16 0dXsg0E8Rm60KJGM-Kym32YF
-rw-r--r-- 1 username username 827905 2010-12-05 19:59 1rOJtQEQ-yd0w6Fsobng4,FfHVr8jQ7YQ6w27nZOxZSpZ0
-rw-r--r-- 1 username username   1108 2010-12-05 19:25 .encfs6.xml
drwx------ 2 username username      0 2012-01-01 21:07 lost+found
-rw-r--r-- 1 username username 254032 2011-03-06 18:08 N-oGdtL0gwHT1jqeA2nKmdB

This data was previously encrypted using encfs.

Encfs
Create another mount point for encfs and mount

$ mkdir /home/username/Crypt

$ encfs /mnt/swissdisk/ /home/username/Crypt/
EncFS Password:

$ ls -al /home/username/Crypt/
total 1059
drwxr-xr-x 3 username username    280 2011-03-06 18:08 .
-rw-r--r-- 1 username username 827897 2010-12-05 19:59 1678_walenstadtberg_1280x800.jpg
-rw-r--r-- 1 username username 254024 2011-03-06 18:08 test-AES256.gpg
-rw-r--r-- 1 username username    123 2010-12-11 17:16 wireless.txt.gpg

$ identify /home/username/Crypt/1678_walenstadtberg_1280x800.jpg 
/home/username/Crypt/1678_walenstadtberg_1280x800.jpg JPEG 1280x800 1280x800+0+0 8-bit DirectClass 828KB 0.010u 0:00.000

Cleanup
When finished unmount encfs mount first, then WebDAV mount.

$ fusermount -u /home/username/Crypt

$ umount /mnt/swissdisk
/sbin/umount.davfs: waiting while mount.davfs (pid 6317) synchronizes the cache .. OK
Comments (0) Trackbacks (0)

No comments yet.


Leave a comment

No trackbacks yet.