I have a ubuntu machine which has different users on it. I wonder if there is a way so I multiple users can login to the same cifs server share using their different ubuntu credentials and different cifs server credentials.

Currently if one of the machine users want to connect, he has to mount to a certain directory like this:

user1@ubuntumachine:~$ sudo mount -t cifs -o "username=serveruser1,uid=$(id -u),gid=$(id -g) //server-address/folder /mount/path_on_ubuntu

and if user2 wants to mount he either has to mount into a different location or he needs to umount user1 first. I wonder if there a way where user1 and user2 can mount into the same to the same directory /mount/path_on_ubuntu?

  • 2 questions: (1) Are these 2 users sequential or concurrent? Does user1 logoff of the client then user2 logs on? Or are they both logged on - on the client - at the same time? (2) Are the credentials passed to the server only meant to limit access to those users or does the server also keep track of what each user does once they are logged in?
    – Morbius1
    Aug 20, 2018 at 11:30
  • @Morbius1 (1) They are both logged at the same time (2)the credentials passed to the server only meant to limit access to those users.
    – Tak
    Aug 20, 2018 at 12:07

1 Answer 1


If the server is set up such that it doesn't restrict what a user can do once he passes the right credentials then one option is to do this in reverse: Limit who can access the mounted share on the client.

Let's say the servers host name is machx:

** Create a group called machx

sudo groupadd machx

** Add all the users who have access to the server to that group:

sudo gpasswd -a morbius machx

** Create a credentials file owned / accessible only to root:

sudo touch /media/.machxcred
sudo chmod 0600 /media/.machxcred

** Within that file add the username and password of one of the expected users in this form:


** Then mount the share specifying access only to users in the "machx" group:

sudo mount -t cifs -o credentials=/media/.machxcred,gid=machx,dir_mode=0770,file_mode=0660,nounix //machx/folder /mount/path_on_ubuntu 
  • The problem is that different users has different folder access, for example when user1 logins with his credentials he will only have access to folder1, while when user2 logins with his credentials (which is different from user1) then he will only have access to folder2.
    – Tak
    Aug 20, 2018 at 14:33
  • 1
    That's just the opposite of how you answered "2)" in my original post. Then why is it required to have it mount at the same place for every client user.
    – Morbius1
    Aug 20, 2018 at 15:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.