Mount cifs for 2 users

I would like to mount a cifs drive for 2 user accounts on a Linux server.

I have no trouble mounting the cifs drive for me, or for sudo, but I need to mount it so that two users can access it:

sudo mount -t cifs -o username=BLAH,password=BLAH,uid=1000,gid=1000 //192.168.168.200/home /mnt/officenas

This works fine for my access, and:

sudo mount -t cifs -o username=BLAH,password=BLAH //192.168.168.200/home /mnt/officenas

works fine for sudo.

How do I allow 2 separate users who don't have sudo access to have read/write access of the same mounted drive?

There are a lot of settings in the man pages which I frankly don't understand, so any help would be appreciated.


Solution 1:

Use the multiuser mount option. Also enable the pam_keyinit.so and pam_cifscreds.so PAM modules. The latter will store the users' OS login passwords in the kernel, so that the cifs driver can use them to log in to the server.

If the usernames or passwords don't match between client & server, pam_cifscreds won't work, but users can manually log in using cifscreds add (which also requires pam_keyinit). Either way, keyctl show can be used to check the keyring contents.

Alternatively, just mount the same share in two different places with different UIDs.