Samba share folder unable to access

Dear all, I tried to share a folder under /home/nicholaswkc/Window_Share

sudo chmod 0775 /home/nicholaswkc/Window_Share
sudo semanage fcontext -a -t samba_share_t "/home/nicholaswkc/Window_Share(/.*)?"

sudo restorecon -Rv /home/nicholaswkc/Window_Share

/etc/samba/smb.conf
[shared]
    comment = Alma Linux Samba Share
    path = /home/nicholaswkc/Window_Share
    browseable = yes
    writable = yes
    guest ok = yes
    valid users = @samba_usr
    create mask = 0664
    directory mask = 0775

sudo groupadd samba_users
sudo useradd -M -s /sbin/nologin smbuser1
sudo usermod -aG samba_users smbuser1
sudo chgrp samba_users /srv/samba/shared
sudo smbpasswd -a smbuser1

sudo firewall-cmd --permanent --add-service=samba
sudo firewall-cmd --reload
sudo systemctl enable --now smb nmb

This is what I have done.

Then, I tried to access it in the alma linux same machine.

smb://127.0.0.1/shared i enter the smbuser1 and password but it fails to connect.

Anyone know what went wrong?

Hello.

Could it be a mistake in the group name in the valid users section of smb.conf (a mismatch between samba_usr and samba_users)?

[shared]
comment=Alma Linux Samba Shared
path=/home/nicholaswkc/Window_Share
browseable=yes
writable=yes
guest ok=yes
valid users=@smbusr
create mask=0664
directory mask=0775

sudo chmod 0775 /home/nicholaswkc/Window_Share
sudo semanage fcontext -a -t samba_share_t “/home/nicholaswkc/Window_Share(/.*)?”

sudo groupadd smbgrp
sudo useradd -M -s /sbin/nologin smbusr
sudo usermod -aG smbgrp smbusr
sudo chgrp smbgrp /home/nicholaswkc/Window_Share/
sudo smbpasswd -a smbusr

Then, I tried access smb://127.0.0.1 which i can access but cannot access using smb://127.0.0.1/shared (On same machine) where it keep prompting login window. I enter the smbusr and password correctly.

I edited the file samba.conf using sudo. I added firewall and selinux already. What could be wrong this time?

Please help. Thanks a lot.

Hello,

I think the problem may be this line:

valid users = @smbusr

In Samba, @ means a group, not a user.
But in your example, smbusr is the user name, and the group you created is smbgrp.

So this should probably be either:

valid users = smbusr

or, if you want to allow the group:

valid users = @smbgrp

That looks like the first thing to fix.

Also, since your share is under /home, it may be worth testing with a simpler path like /srv/samba/shared first, just to rule out any SELinux or home-directory related issues.

After updating smb.conf, please also run testparm and then try:

smbclient -L localhost -U smbusr

and

smbclient //localhost/shared -U smbusr

So, at least from what you posted, the most likely issue is that valid users is pointing to the wrong name.

[shared]
comment=Alma Linux Samba Shared
path=/srv/samba/
browseable=yes
writable=yes
guest ok=yes
valid users=@smbgrp
create mask=0664
directory mask=0775

sudo mkdir -p /srv/samba/

sudo chown -R nobody:nobody /srv/samba
sudo chcon -t samba_share_t /srv/samba
sudo chcon -t samba_share_t /srv/samba

When i running this coomand,

smbclient -L localhost -U smbusr

Sharename       Type      Comment
---------       ----      -------
print$          Disk      Printer Drivers
shared          Disk      Alma Linux Samba Shared
IPC$            IPC       IPC Service (Samba 4.22.4)
smbusr          Disk      Home Directories

SMB1 disabled – no workgroup available

When running this command,

smbclient //localhost/shared -U smbusr

Try “help” to get a list of possible commands.
smb: >

A billion thanks for your help. Appreciate it.

Hello,

I think the main problem is this line:

valid users = @smbusr

@smbusr means a group, not the user smbusr.

So please change it to either:

valid users = smbusr

or, if you want to use the group:

valid users = @smbgrp

Also, because the share is under /home/..., the parent directory permissions may also block Samba access.

Thanks.