I am able to mount a drive to the linux box using sudo.
sudo mount \
-t cifs \
-o 'vers=3.0,username=myuser,domain=mydomain' \
'//windows-ip/share-folder' ~/testmount/
This works great, problem is, when I go into the ~/testmount and do sometihng like mkdir
it says:
mkdir: cannot create directory ‘bkup’: Permission denied
It will work if I use sudo
We are going to have an automated script in a cronjob write files to these mounts so, we need to be able to write to the mounts without sudo
.
So after it’s mounted I’m unable to add files to that folder unless I use sudo
and that's the problem.
It seems my problem is very similar to this one, but the solutions for that one didn't work for me:
Someone suggested the problem was that I used sudo to mount it and therefore had to use sudo to change anything in it (even though I don't need to use sudo to read stuff in it).
So, I found answers like these:
https://unix.stackexchange.com/questions/365308/use-mount-o-with-a-non-root-user https://wiki.ubuntu.com/MountWindowsSharesPermanently
I even tried to implement the solutions suggested but was still unable to get those solutions to work either.
My etc/fstab has this line:
//windows-ip/share-folder \
/home/mysuer/testmount \
cifs \
uid=myuser,credentials=/home/myuser/.smbcredentials,iocharset=utf8,domain=my-domain 0 0
With the above setup when I try to run mount without sudo I get an error:
$ mount ~/testmount
mount: only root can mount //10.1..../shared on /home/.../testmount
The reason I need to be able to write to these mounted folders without sudo because we will have an automated system saving files and I don't think it should use sudo, and I don’t even know if it could if we wanted it to.
I'm on centos 7. Perhaps you can't put the 'domain' option in the fstab, I don't know. can anyone help me with this?