I want to mount a Windows share using CIFS on my Ubuntu 17.04 machine. I want to use an SMB credentials file for the authentication details, but always get "mount error(13): Permission denied" if I try to use a credentials file. If I embed the username/password in the mount command line I have no problems.

For example, this command fails with "mount error(13): Permission denied":

sudo mount -t cifs //servername/sharename /home/myuser/mediafolder -o credentials=/home/myuser/.smbcredentials,dir_mode=0777,file_mode=0777

But this command works fine, and mounts the share correctly:

sudo mount -t cifs //servername/sharename /home/myuser/mediafolder -o user="My User",pass=MyPassword,dir_mode=0777,file_mode=0777

My .smbcredentials file looks like this:

username='My User'

After creating the .smbcredentials file I did this:

sudo chown root .smbcredentials
sudo chmod 600 .smbcredentials

Finally, I should add that I've been executing all of these commands in a VNC session from a Windows VNC client (I don't know if that's relevant).

Any idea what's wrong with my .smbcredentials file?

  • Just wondering: Are you sure about the workgroup? This parameter is optional and you didn't give it in the user/password version. – muclux Nov 30 '17 at 21:07
  • I successfully use a credentials file. I don't have the single quotes on the username, and I don't supply a workgroup. – Organic Marble Nov 30 '17 at 21:25
  • I've also tried it without the workgroup parameter and got the same error. Unfortunately my Windows username has an embedded space, so I believe that the quotes are essential? – Ian M Nov 30 '17 at 21:40
  • Yes, I'd imagine so. Perhaps root owning it is wrong? I own my credentials file, with permissions of 600 (same permissions as you). I'd at least try that. – Organic Marble Nov 30 '17 at 23:01

So it seems that the quotes in my .smbcredentials file were not required after all. I changed the first line to:

username='My User'

and do not get the error message any more

  • Sorry that code example should have excluded the quote marks! – user1175461 Nov 30 '17 at 23:19
  • Could you edit your answer, so it is easier for future reference? – Marc Vanhoomissen Dec 4 '17 at 15:40

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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