You can't do what you've asked, but there are three alternatives I'll describe here

  1. Include a syntactically valid smb.conf snippet that defines your users.

     valid users = user1, user2, user3
    

    Include this snippet in your share definition. For example, if the snippet is called /usr/local/etc/smb.valid_users.conf you would declare your share like this

     [example share]
     path = /example/path/here
     read only = no
     guest ok = no
     include = /usr/local/etc/smb.valid_users.conf
    

    When you change the list of users you may need to restart samba (systemctl restart smbd). Notice that because this is an include, any valid code can be added - including entire shares that give away far more access than you would expect. Do not allow untrusted users access to change the configuration file!

  2. Put the users into a group and reference the group in the share definition.

     valid users = @usersgroup
    

    Then exactly as usual you create the group usersgroup (see groupadd or addgroup depending on your OS variant) and add your users to it

  3. Template the smb.conf and substitute into it as necessary. (The least favourite of my options.) Copy smb.conf to smb.conf.template and use this line in your share definition,

     valid users = %USERSLIST%
    

    Then use something like sed to substitute into the template

     sed 's/%USERSLIST%/user1, user2, user3/g' /etc/samba/smb.conf.template >/etc/samba/smb.conf
    
Answer from Chris Davies on Stack Exchange
🌐
Samba
samba.org › samba › docs › using_samba › ch09.html
Chapter 9. Users and Security
An example follows: [sales] path = /home/sales comment = Sedona Real Estate Sales Data writable = yes valid users = sofie shelby adilia admin users = mike · This option takes both group names and usernames. In addition, you can specify NIS netgroups by preceding them with an @ as well; if the netgroup is not found, Samba will assume that you are referring to a standard Unix group.
🌐
Red Hat
access.redhat.com › solutions › 2262051
How to secure samba share access using 'valid users' parameters along with local samba groups with security=ads. - Red Hat Customer Portal
[root@rhel6 ]# cat /etc/samba/smb.conf [global] workgroup = EXAMPLE realm = EXAMPLE.COM security = ADS winbind enum users = Yes winbind enum groups = Yes winbind use default domain = No idmap config * : backend = autorid idmap config * : range = 1000000-19999999 idmap config * : rangesize = 1000000 template shell = /bin/bash winbind use default domain = yes [share] comment = Test Share path = /share read only = no public = yes valid users = +localgroup <----
Discussions

linux - Link samba valid users to text file - Unix & Linux Stack Exchange
In my samba config - I would like it to link "valid users" in the example share below to the example text file: security = user [example share] path = /example/path/here read only = no g... More on unix.stackexchange.com
🌐 unix.stackexchange.com
linux - How do I define a samba share so that every user can only see its own home? - Unix & Linux Stack Exchange
I would like to make every user's ... default Samba configuration) I can access other users /homes. ... [homes] comment = Home Directories browseable = no public = no read only = no create mask = 0700 directory mask = 0700 valid users = ashley joe %S · By logging on ashley's account from Windows 7 machine I can browse joe's home. How should I configure this ? ... I think you should change valid users = ashley joe %S to only valid users = %S. In your example, ashley, joe ... More on unix.stackexchange.com
🌐 unix.stackexchange.com
April 19, 2012
iOS Files App connects to Samba as Read-Only, but other apps work perfectly.
Try to add this to /etc/samba/smb.conf: `vfs objects = streams_xattr` And restart. It works well for me in Samba 4.22.4 on Debian 13. More on reddit.com
🌐 r/selfhosted
9
4
November 15, 2025
SMB share only works in read-only
Better to ask in r/linux But I will ask this. What are the permissions on those directories set as and is your myusername part of the group or user with permissions there? More on reddit.com
🌐 r/selfhosted
4
0
February 17, 2024
🌐
O'Reilly
oreilly.com › openbook › samba › book › ch06_02.html
[Chapter 6] 6.2 Controlling Access to Shares
An example follows: [sales] path = /home/sales comment = Fiction Corp Sales Data writeable = yes valid users = tom dick harry admin users = mike · This option takes both group names and usernames. In addition, you can specify NIS netgroups by preceding them with an @ as well; if the netgroup is not found, Samba will assume that you are referring to a standard Unix group.
🌐
Linux Mint Forums
forums.linuxmint.com › board index › main edition support › networking
Understanding "valid users" in smb.conf (SOLVED) - Linux Mint Forums
May 14, 2025 - [Documents-userA] path = /home/userA/Documents read only = no valid users = userA, userB force user = userA guest ok = no In this case samba will allow access to either user but the force user will make them both appear to be userA to Linux which may not be what you want.
🌐
Linux-training
linux-training.be › storage › ch23.html
Chapter 23. samba securing shares
To restrict users per share, you ... /srv/samba/tennis comment = authenticated and valid users only read only = No guest ok = No valid users = serena, kim, venus, justine...
Find elsewhere
🌐
O'Reilly
oreilly.com › openbook › samba › book › ch06_01.html
[Chapter 6] Users, Security, and Domains
This is shorthand for saying that the valid users are represented by the Unix group account. These users will need to be added to the group entry account in the system group file ( /etc/group or equivalent) to be recognized as part of the group. Once they are, Samba will recognize those users as valid users for the share.
🌐
SUSE
suse.com › support › kb › doc
valid users with AD group | SUSE | Support Center
Instead of valid users = @"<domain>\<AD group>", try valid users = +"<domain>\<AD group>". Restart of samba service is required after changing it.
🌐
OneUptime
oneuptime.com › home › blog › how to configure samba user authentication and permissions on rhel
How to Configure Samba User Authentication and Permissions on RHEL
March 4, 2026 - When user "jdoe" connects to a share called "jdoe", Samba points it to their home directory. ... # Set minimum password length sudo pdbedit -P "min password length" -C 8 # Set password history sudo pdbedit -P "password history" -C 5 # View current policies sudo pdbedit -P "min password length" sudo pdbedit -P "password history" [confidential] path = /srv/samba/confidential valid users = @samba_admins invalid users = tempuser baduser
🌐
Samba
samba.org › samba › docs › 4.1 › man-html › smb.conf.5.html
smb.conf
The valid values are: manual, documents, programs, disable. These values correspond to those used on Windows servers. For example, shares containing roaming profiles can have offline caching disabled using csc policy = disable. ... If you set clustering=yes, you need to tell Samba where ctdbd ...
🌐
Jaytaala Confluence
confluence.jaytaala.com › display › TKB › Create+samba+share+writeable+by+all,+group,+or+only+a+user
Create samba share writeable by all, group, or only a user - Tech Knowledge Base - jaytaala.com Confluence
August 25, 2020 - We now need to edit /etc/samba/smb.conf. Below are several examples depending on how you want to users to access your smb share. ... # share [share] path = /media/share writeable = yes browseable = yes public = yes create mask = 0644 directory mask = 0755 force user = shareuser ... Note: you should have created group "sharegroup" (or another group) as outlined above. ... # share [share] path = /media/share valid users = @sharegroup writeable = yes browseable = yes create mask = 0644 directory mask = 0755 force user = shareuser ...
🌐
Linuxtopia
linuxtopia.org › online_books › network_administration_guides › using_samba_book › ch06_01_00.html
Using Samba - 6.1 Users and Groups
Contents: Users and Groups Controlling Access to Shares Authentication Security Passwords Windows Domains Logon Scripts · This chapter discusses how to configure users with the Samba server. This topic may seem straightforward at first, but you'll soon discover that there are several ancillary ...
🌐
Medium
medium.com › @yusufcelik1 › samba-configuration-and-usage-guide-f00cac3e3830
Samba Configuration and Usage Guide | by Yusuf Celik | Medium
November 18, 2024 - Each share section defines a network share and its properties. Here’s an example of a simple share configuration: [shared] path = /path/to/shared/folder valid users = user1, user2 read only = no browsable = yes writable = yes
🌐
TechRepublic
techrepublic.com › home › security
How to manage user security in Samba - TechRepublic
October 24, 2016 - [Editorial] ​ path = /data/editorial ​ read only = no ​ writeable = yes ​ browseable = yes ​ valid users = @editorial ​ create mask = 0660 ​ directory mask = 0770 · The crucial bit is the @ character, which tells Samba that editorial is a group and not a user.
🌐
Linux-training
linux-training.be › networking › ch21.html
Chapter 21. samba securing shares
To restrict users per share, you ... /srv/samba/tennis comment = authenticated and valid users only read only = No guest ok = No valid users = serena, kim, venus, justine...
🌐
Linux Questions
linuxquestions.org › questions › linux-software-2 › help-with-samba-share-browseable-and-valid-user-4175526381
help with samba share - browseable & valid user ?
in samba there is a default option in the gui to allow user's home directories to be shared out. it's called or named Homes. The other is named Users
🌐
ServerSpace
serverspace.us › support › help › configuring-samba
Configuring Samba | Serverspace
June 7, 2023 - [global] workgroup = WORKGROUP security = user map to guest = bad user wins support = no dns proxy = no [public] path = /media/samba/public guest ok = yes force user = nobody browsable = yes writable = yes [private] path = /media/samba/private valid users = @smbgrp guest ok = no browsable = yes writable = yes