Mount CIFS Permission Denied on Linux - Fixed!

In this tutorial, I show you how to fix the Mount CIFS Permission Denied error on Linux.

Table of Contents

Mount CIFS Permission Denied Error

The error occurs mostly because you don't provide sufficient credential information, specifically which Domain you are in. Most Tutorials out there only mention username and password when editing the .smbcredentials file. But let me take you through the process from the beginning.

Step 1 - Installing CIFS Utils

To mount a CIFS share on Linux, we first need to install cifs-utils. Let's get started with that.

sudo apt-get install cifs-utils -y
Code language: JavaScript (javascript)

It should probably be pre-installed in most distros anyway.

Step 2 - Creating a Mount Point

Next, we need to create the directory where we want to Mount our Share in. You can later find the Share in this Directory. For this example, we will mount the imaginary "Photos" share.

sudo mkdir /media/share/Photos

Step 3 - Editing the fstab file

That we don't have to mount our Share again after each reboot, we have to edit the fstab file to make the Share mount automatically after each reboot. But first, we make a backup of this file in case something goes wrong.

sudo cp /etc/fstab /etc/fstab.old

That done, we edit our fstab file.

sudo gedit /etc/fstab

And paste this line at the end of the file (all in one line)

//YourServer/Photos /media/share/Photos/ cifs vers=2.0,credentials=/home/YourLinuxUsername/.smbcredentials,iocharset=utf8,gid=1000,uid=1000,file_mode=0777,dir_mode=0777 0 0
Code language: JSON / JSON with Comments (json)

Of course, adjust accordingly to your own Server and YourLinuxUsername! We will create the .smbcredentials file next.

By default, you will have the gid=1000 and uid=1000. That's your Group & User ID, but to make sure that those values are the same in your system, double-check it by typing:

id
mount cifs permission denied

If all is correct, hit CTRL+S to Save the fstab file and close it.

mount cifs permission denied

Step 4 - Creating the .smbcredentials file

We could enter our username directly into our fstab file, but that would not be safe as someone could clearly read our Username and Password in this unencrypted file. Therefore, we are going to create a separate file containing this information.

sudo gedit .smbcredentials
Code language: CSS (css)

And here is the key point to fixing the Mount CIFS Permission Denied error. Most guides simply state to enter Username and Password into this file, but you also have to enter your Domain!

So paste this into your .smbcredentials file:

username=yourusername password=yourpassword domain=yourdomain

Save & Close the file.

Now we just make the .smbcredentials file so that only the root user can read its contents.

sudo chmod 600 ~/.smbcredentials

Step 5 - Mounting the Share

Now when everything is done, try to mount the share by typing

sudo mount -a

And your share should now be successfully mounted!  If there are still some errors, try rebooting your system and see again if the Share was mounted. The share should be located in your media/share/Photos folder.

Wrapping up

It took me a while to figure out this error. I use a Synology NAS and had to set vers=2.0 in the fstab file. If you still encounter problems, try changing vers to 1.0 or 3.0. Let me know in the comments below if this solution worked for you!

13 thoughts on “Mount CIFS Permission Denied on Linux - Fixed!”

  1. Great tutorial. I am new to Linux and while this works great when running the "sudo mount -a" command. Every time I reboot Ubuntu, it loses the mount and does not automatically mount. Any suggestions?

    Reply
  2. Stefan, great tutorial. I followed it closely as prescribed... and then modified fstab as follows to have "receiving" folders under user "Pi". Either way, still get "mount.cifs permission denied"! Is access denial my Buffalo 4TB NAS (with SMB turned ON) or the Pi 3 on LAN?

    My fstab: //192.168.0.100/LS210xxnn/pub_music /home/pi/myNAS/pub_music cifs vers=2.0,credentials=/home/pi/.smbcredentials,iocharset=utf8,gid=1000,uid=1000,file_mode=0777,dir_mode=0777 0 0

    Plan to add to fstab for pub_photos, pub_video, once "pub_music" working!

    Should fstab have Buffalo's LS210xxnn name as well as its domain and the desired share?
    Thanks for help!

    Reply
    • P.S. For the NAS, using logonid=guest; password= (written this way representing "blank"; in Lenix should password=" " instead?

      Reply
  3. thank you for your help. I got my share drive mounted. now, what if I have more than one share drive on the same domain?

    Reply
  4. When I try to mount with sudo mount I get the error:
    mount error(13): Permission denied

    It is evident that you lie!!!

    Reply
    • According to the other comments, it would almost appear you do something wrong. But since it is almost evident that I lie, I am not going to help you :p

      Reply
  5. Great article, I'm able to successfully create the mount and see files in the share, however; I am unable to create or write to the directory. Is there something else not included in the article which I need to configure?

    Reply
  6. Good start/thinking about writing this. However 2 things: 1. when editing .smbcredidentials you should specify that it's under ~ and 2. when mounting it asks for a root password. So even though your tutorial is nice it doesn't work.

    Reply

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.