Linux – How to pass credential file to mount.cifs

cifslinuxmountsamba

I'm maintaining a heterogeneous network of mac and linux so I decided to create a little perl script to unify mounting strategies across machines.

The current implementation in linux is in /etc/fstab works fine:

//myserverhere.com/cifs_share /mnt/cifs_share cifs
user,uid=65001,rw,workgroup=DEV,credentials=/root/.cifs 0 0

and /root/.cifs contains

username=ouruser
password=ourpassword

I tried translating that to a non-fstab format as follows:

mount.cifs //myserverhere.com/cifs_share /mnt/cifs_share user,uid=65001,rw,workgroup=DEV,credentials=/root/.cifs

But it doesn't seem to work.

Can someone point out what I'm doing wrong please?

Thanks in advance.

Ismael Casimpan 🙂

Best Answer

Syntax of mount.cifs:

mount.cifs {service} {mount-point} [-o options] 

You need to pass the options after the "-o". For example, with your given options, your command should be:

mount.cifs //myserverhere.com/cifs_share /mnt/cifs_share \
    -o user,uid=65001,rw,workgroup=DEV,credentials=/root/.cifs

(I didn't test the options you gave.)