I am encountering a problem in which mounting a remote CIFS server without an fstab entry works, but mounting through fstab does not.

The following command works:

$ sudo mount -t cifs //w.x.y.z/Home$ /mnt/dir -o domain=A,username=B,password='C',sec=ntlmssp,file_mode=0700,dir_mode=0700

However, if I instead add the following line to /etc/fstab and try to mount by the mount command (e.g., mount -a or mount /mnt/dir), I receive the error listed below:

$ tail -n 1 /etc/fstab
//w.x.y.z/Home$ /mnt/dir cifs domain=A,username=B,password='C',sec=ntlmssp,file_mode=0700,dir_mode=0700


$ sudo mount /mnt/csif
mount error(13): Permission denied
Refer to the mount.cifs(8) manual page (e.g. man mount.cifs)

Explicitly setting dump and fsck pass order to 0 does not help. Both commands seem to do the same thing


When you type the mount command, the part password='C' is first handled by the shell and becomes password=C before it gets to the mount command. This is not done with fstab entries, so you must remove the single quotes. If your password contains special characters you can replace them by their octal code, in particular \040 for space.

  • I needed to use quotes to avoid shell interpolation of special characters in the password. Removing the quotation marks in conjunction with substitution of octal values for the password's special characters solved my problem. Thank you. – user001 Apr 13 '16 at 23:24

It's good practice to avoid putting passwords directly in /etc/fstab (which is normally world-readable). Instead, put them into a file, and reference the file like:

//w.x.y.z/Home$ /mnt/dir cifs credentials=/home/username/cifs.creds,sec=ntlmssp,file_mode=0700,dir_mode=0700

/home/username/cifs.creds is owned by a suitable user (either root, or a user that corresponds to the SMB user who owns the SMB share), and chmod og-rwx. It contains the credentials in the format


A, B and C above must be literal - there's no shell-like parsing of quotes or backslashes.

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.