I think I'm encountering the same problem you have. For some reason force user seems to require group write permissions. It does not appear to require world write permissions though, so as a workaround you should be able to get away with 660/770 permissions rather than 777. This shouldn't reduce security; it's just annoying to move files into it outside of samba since you need to make them group-writeable.

Put this in your smb.conf under [Stuff]:

force user = myuser
create mask = 0660
directory mask = 0770

Then run this on your share folder:

sudo chown -R myuser:myuser /home/myuser/share
sudo chmod -R 0660 /home/myuser/share
sudo chmod -R ug+X /home/myuser/share

Then restart smbd. The above will set all files to 660 and all directories to 770, for currently existing files and for files newly created through samba. Note that you don't need force group; by default it matches the primary group of force user. Also note that I'm denying world permissions entirely here. You could probably use 0664, 0775 and ugw+X instead if you want them world-readable.

Unfortunately I haven't been able to make it work without group write permissions. I suspect it's a bug in samba. The recent samba bug #14617 prevented deleting files via force user. It's possible this is another related bug but I don't know enough about it to report it. If you figure out how to get it working with 0644/0755 please let me know!

Answer from ludocode on Stack Exchange
Top answer
1 of 3
11

I think I'm encountering the same problem you have. For some reason force user seems to require group write permissions. It does not appear to require world write permissions though, so as a workaround you should be able to get away with 660/770 permissions rather than 777. This shouldn't reduce security; it's just annoying to move files into it outside of samba since you need to make them group-writeable.

Put this in your smb.conf under [Stuff]:

force user = myuser
create mask = 0660
directory mask = 0770

Then run this on your share folder:

sudo chown -R myuser:myuser /home/myuser/share
sudo chmod -R 0660 /home/myuser/share
sudo chmod -R ug+X /home/myuser/share

Then restart smbd. The above will set all files to 660 and all directories to 770, for currently existing files and for files newly created through samba. Note that you don't need force group; by default it matches the primary group of force user. Also note that I'm denying world permissions entirely here. You could probably use 0664, 0775 and ugw+X instead if you want them world-readable.

Unfortunately I haven't been able to make it work without group write permissions. I suspect it's a bug in samba. The recent samba bug #14617 prevented deleting files via force user. It's possible this is another related bug but I don't know enough about it to report it. If you figure out how to get it working with 0644/0755 please let me know!

2 of 3
2

OK, have you created users with 'smbpasswd -a username' (needs to be run as root) ? If you haven't, then your guest account 'myuser' will not work. This means that no one will be able to access your share. Authentication (based on your smb.conf) works like this: A user connects to Samba and if the user is known and supplies the correct password, they are allowed access to your share, but anything they save will be saved as if belonging to 'myuser', but they will be able to read and write files. If they are a known user, but supply a wrong password, then the connection is silently dropped. Because you have 'map to guest = bad user' in global and 'guest ok = yes' in the share, an unknown user that connects to Samba will be mapped to the guest account 'myuser' before it gets anywhere near the share and as they are now a known user, they will be allowed access to the share. As for the smb.conf being too short, well, yours could be even shorter. You do not need the 'force group' line, the 'force user' will do that for you, also as 'myuser' has write permissions by default, you do not need the 'write list' line. Finally, you never need to set 'browseable = yes' anywhere, it is a default setting.

🌐
Ask Ubuntu
askubuntu.com › questions › 913069 › samba-shares-only-work-with-force-user
permissions - Samba shares only work with "force user" - Ask Ubuntu
Of course, I also added all these users to the Samba users DB. However, I wasn’t able to access any of these folders from any machine using any possible user account (Windows always says “You don’t have the permission to access …”). I then added a line force user = nas to each share declaration, changed the ownership of each folder to nas:nas and changed the user permissions to 700. Now everything works like a charm!
Discussions

How to create a Samba share that is writable from Windows without 777 permissions? - Unix & Linux Stack Exchange
Folder was 775, create and dir mask was 775 but in Windows it was not writable and I could not get why. Adding force user = defaultUser did the job for me. ... I got it, the problem was the location of smb.conf. Google and even sambas documentation said the file should be at /usr/local/samba/lib ... More on unix.stackexchange.com
🌐 unix.stackexchange.com
macos - samba does not allow force user - Stack Overflow
Bring the best of human thought ... at your work. Explore Stack Internal ... I am using Samba 3.6.6 on Debian Wheezy. I want to be able to change www files on my dev server using my macbook. So I setup samba and made a share for the /var/www directory. I added the users bart & root to samba to connect. And connect using command K and then smb://192.168.2.100 (my samba server). As apache uses www-data as a user and group for the www files I use force user and force ... More on stackoverflow.com
🌐 stackoverflow.com
Samba force user?
Please Re-Flair your post if a solution is found. How to Flair a post? This allows other users to search for common issues with the SOLVED flair as a filter, leading to those issues being resolved very fast. I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns. More on reddit.com
🌐 r/linuxmint
4
3
October 13, 2023
"force user = smbuser"
Is there way to disable these options that enabled by default: force user = smbuser force group = smb ? Use case: sharing docker volume (mapped to host path) and using specific "user id" ... More on github.com
🌐 github.com
8
November 13, 2019
Top answer
1 of 5
103

I recommend to create a dedicated user for that share and specify it in force user(see docs).

Create a user (shareuser for example) and set the owner of everything in the share folder to that user:

adduser --system shareuser
chown -R shareuser /path/to/share

Then add force user and permission mask settings in smb.conf:

[myshare]
path = /path/to/share
writeable = yes
browseable = yes
public = yes
create mask = 0644
directory mask = 0755
force user = shareuser

Note that guest ok is a synonym for public.

2 of 5
6

In the share settings in smb.conf, you'll need to specify the names of users and/or groups that are allowed to write to the share, using a write list = ... line.

Example:

[myshare]
...
write list = my_linux_username

Then you'll need to use the smbpasswd command to set up a password to authenticate my_linux_username for Samba:

sudo smbpasswd -a my_linux_username

This step is necessary because the standard system passwords in /etc/shadow are hashed in algorithms that are incompatible with the password hash algorithms used in the SMB protocol. When a client sends a SMB authentication packet, it includes a hashed password. It can only be compared to another password hash that uses the same algorithm.

(Very, very old instructions from the previous millennium may recommend disabling password encryption in Samba, and using certain registry hacks to allow Windows to emit unencrypted passwords to the network. This advice is obsolete: those registry hacks may no longer work in current versions of Windows, and allow anyone who can monitor your network traffic to trivially capture your password.)


There's one more thing you may have to do client-side. When your Windows client system is joined to an Active Directory domain and you're logged in with an AD account, it automatically prefixes all unqualified usernames with the name of the AD domain of the user, i.e. you will be authenticating as AD_DOMAIN\your_username, not just your_username.

If you are logged in with a local account (or your client system is not joined to an AD domain), Windows may automatically prefix the username with the client hostname unless you specify another domain name.

To successfully log in to a stand-alone Samba server from a stand-alone Windows client, you may have to specify your username as SAMBA_SERVER_HOSTNAME\your_username.

Otherwise Samba will see the username as WINDOWS_CLIENT_HOSTNAME\your_username, conclude that it has no way to verify any users belonging to domain named WINDOWS_CLIENT_HOSTNAME, and will reject the login.

(Newer versions of Samba may have a built-in check for this specific situation, and they might allow you access nevertheless. But this is basically how SMB authentication works "under the hood", and if you need to deal with old versions of Samba, it might be useful still.)

🌐
Red Hat
bugzilla.redhat.com › show_bug.cgi
1135723 – [Samba] Does not work 'force user' from a client machine Windows 8.1 x64.
article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution ...
🌐
Red Hat
access.redhat.com › solutions › 7041564
Adding force user/group in smb.conf breaks Samba - Red Hat Customer Portal
The share must contain files whose ownership is a local user in linux, so the configuration options force user and force group in /etc/samba/smb.conf are needed. In this configuration, the target shared directory gets not accessible from the Windows client side.
Find elsewhere
🌐
Samba
samba.samba.narkive.com › jQZxe7h7 › force-user-not-working
[Samba] force user not working
For all of my common directories (each dept has a commond dir that only their dept can access) I have "Force User = %U". This is important, because without it the created files do not apply to the user's quota. I wish to stress that this did *not* happen with 2.0.7... it worked just as it should.
🌐
Server Fault
serverfault.com › questions › 1040360 › issues-with-force-user-on-samba-4-7-active-directory-authentication
linux - Issues with "force user" on Samba 4.7 + Active Directory authentication - Server Fault
October 28, 2020 - The folder permissions are 0700, user oracle, ID 1001. I set the folder 777 to try out, and it works, created a file, then i check the IDs owner to the files created through Samba, looks like Samba is forcing user "oracle" from Active Directory (there is also a user with this name there) instead of forcing the local unix user.
🌐
Red Hat
bugzilla.redhat.com › show_bug.cgi
910735 – force user in smb.conf stopped working after update to 4.0.3
February 26, 2013 - Red Hat Bugzilla – Bug 910735 · This site requires JavaScript to be enabled to function correctly, please enable it · Privacy Contact FAQ Legal
🌐
Samba
bugzilla.samba.org › show_bug.cgi
9746 – guest ok + force user + force group doesn't work
The Samba-Bugzilla – Bug 9746 guest ok + force user + force group doesn't work Last modified: 2013-05-09 18:06:22 UTC
🌐
Samba
lists.samba.org › archive › samba › 2012-November › 169910.html
[Samba] force user not working
November 1, 2012 - strange this is, the share is a copy of other server ( the settings ) and on other server its working ok. this is the share : [dbspool] comment = Aftermath Database Spooling path = /home/dbspool browseable = yes writeable = yes read list = @"DOMAINNAME\groupname" write list = @"DOMAINNAME\groupname" force user = username force group = groupname create mode = 666 directory mode = 777 wide links = yes follow symlinks = yes Very this i copy to the share has user root ( and this is correct since my user is also in the Domain Admins group ) but with force user it should be username and not root. Im missing something, but can see what. the logs are error free. Best regards, Louis · Previous message: [Samba] sambar4: user creation with ldap and initial password
🌐
Samba
samba.org › samba › docs › using_samba › ch08.html
Samba
If this option is not set, however, and a Windows user attempts to mark a file hidden on a Samba share, it will not work—Samba has no place to store the hidden attribute! For map archive to work properly, the execute bit for other must not be masked off with the create mask parameter. When the inherit permissions option is set to yes, the create mask, directory mask, force ...
🌐
LinuxQuestions.org
linuxquestions.org › questions › linux-server-73 › samba-force-group-not-working-4175679079
[SOLVED] SAMBA - force group not working
July 20, 2020 - Hey folks - this is my first post... my Linux experience goes back to the 90's but I have been out for a long time. My current environment is:
🌐
Super User
superuser.com › questions › 512702 › samba-3-5-force-user-doesnt-seem-to-be-sticking
linux - samba 3.5 "force user" doesn't seem to be sticking - Super User
November 30, 2012 - [global] workgroup = WORKGROUP server string = Samba Server Version %v netbios name = luna security = share # logs split per machine log file = /var/log/samba/log.%m log level = 2 # max 50KB per log file, then rotate max log size = 50 winbind use default domain = Yes [strge] comment = please path = /storage browseable = yes read only = no force user = windowsguest force group = users guest ok = yes
🌐
GitHub
github.com › dperson › samba › issues › 253
"force user = smbuser" · Issue #253 · dperson/samba
November 13, 2019 - Is there way to disable these options that enabled by default: force user = smbuser force group = smb ? Use case: sharing docker volume (mapped to host path) and using specific "user id" matching host user, such that new files have "user...
Author   dperson
🌐
SambaWiki
wiki.samba.org › index.php › Setting_up_Samba_as_a_Standalone_Server
Setting up Samba as a Standalone Server - SambaWiki
January 7, 2026 - Samba can be configured to automatically create linux user accounts after successful samba authentication, using the [global] add user script smb.conf option. Unfortunately this option does not work as intended at end-user access time, but it can be leveraged to simplify adding users to your samba Standalone Server.
🌐
Linux Mint Forums
forums.linuxmint.com › board index › main edition support › beginner questions
Samba Sharing [SOLVED] - Linux Mint Forums
[share1] path = /export/share1 ... group = nogroup · drwxr-xr-x 4 root root 4096 May 3 07:10 share1 A samba share doesn't have the authority to override the Linux permissions of what is being shared....