5

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 

error:

$ 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

2 Answers 2

9

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

domain=A username=B password=C 

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

7

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.

1
  • 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. Commented Apr 13, 2016 at 23:24

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.