Latest Post :
Recent Post

Mount CIFS Permission Denied on Linux

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 0Code 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
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!

{[['']]}
 
๐•พ๐–š๐–•๐–•๐–”๐–—๐–™ : ๐•ฎ๐–—๐–Š๐–†๐–™๐–Ž๐–“๐–Œ ๐–‚๐–Š๐–‡๐–˜๐–Ž๐–™๐–Š ๐“จ3๐“š๐“—
๐•ฎ๐–”๐–•๐–ž๐–—๐–Ž๐–Œ๐–๐–™ © 2011~2019 Pro Skill - ๐•ฌ๐–‘๐–‘ ๐•ฝ๐–Ž๐–Œ๐–๐–™๐–˜ ๐•ฝ๐–Š๐–˜๐–Š๐–—๐–›๐–Š๐–‰
๐•ฟ๐–Š๐–’๐–•๐–‘๐–†๐–™๐–Š ๐•ฎ๐–—๐–Š๐–†๐–™๐–Ž๐–“๐–Œ ๐–‚๐–Š๐–‡๐–˜๐–Ž๐–™๐–Š ๐•ป๐–š๐–‡๐–‘๐–Ž๐–˜๐–๐–Š๐–‰ ๐–‡๐–ž ๐“จ3๐“š๐“—
๐•ป๐–—๐–”๐–š๐–‰๐–‘๐–ž ๐–•๐–”๐–œ๐–Š๐–—๐–Š๐–‰ ๐–‡๐–ž ๐•ญ๐–‘๐–”๐–Œ๐–Œ๐–Š๐–—