Samba share is not mounting with normal user rights

I am using the below script and trying to mount the samba mount with normal user with domain permission but always i am getting error saying “mount.cifs: permission denied: no match for /home/xxxx@yours.com/xxx_mnts/cdata/xxx_PROJECTS found in /etc/fstab”

#!/bin/bash

Get the logged-in username

username=$(whoami)

Create the directory if it doesn’t exist

mkdir -p “/home/${username}/xxx_mnts/oudata/xxx_PROJECTS”

chown -R “${username}”:“domain users” “/home/${username}/xxx_mnts/oudata/xxx_PROJECTS”

chmod -R 755 “/home/${username}/xxx_mnts/oudata/xxx_PROJECTS”

#Add user to the mount group

sudo usermod -a -G mount ${username}

Get the UID and GID of the user

uid=$(id -u “$username”)

gid=$(id -g “$username”)

Construct the mount command

mount_command=“mount.cifs //oudata/xxx_PROJECTS /home/${username}/pfx_mnts/oudata/xxx_PROJECTS/ -o _netdev,username=${username},domain=xxx.com,uid=${uid},gid=${gid},sec=krb5,vers=2.1”

Mount the directory using the mount.cifs command

eval “$mount_command”

Check the exit status of the mount command

if [ $? -eq 0 ]; then

echo “Mount command executed successfully.”

else

echo “Mount command failed.”

fi

Please help to find what i am doing wrong

OK, first thing is that the username is ‘xxxx@yours.com’, are your usernames in this format ?
Unless you have changed something, mount must be run by root or with sudo.

What works for me between two Samba Unix domain members is:

sudo mount -t cifs //testdm.samdom.example.com/data_share /srv/smb_share -o cruid=username,user=username,sec=krb5i,uid=11104,gid=10513

Where ‘data_share’ is the share on the FQDN server ‘testdm.samdom.example.com’ which is mounted into ‘/srv/smb_share’ locally.

Thanks for the reply!!! Please find my reply below
“OK, first thing is that the username is ‘xxxx@yours.com’, are your usernames in this format? I have edited this place to avoid exposing my domain. And I forgot to mention that with sudo and root access, the said script is working well, but it is not helping me to gain the folder access policy from my AD.”---- SO trying to mount the shares using the direct user permission which is not happening

I realised that you had sanitised the command, but is the username being set to ‘xxx@yours.com’ (that is the UPN) ?
I can logon using ‘DOMAIN\username’ , ‘username’ and ‘username@dns.domain.tld’, but this is using Samba without sssd.
The sample mount command I posted is a working example, just sanitised.

Hi Thank you for your support and i wan to inform you that i have successfully mounted with proper permission using the script as sssd properly configured. Thanks for github co pilot which helped me in fixing the same

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.