Samba has its own layer of access control for each share. There are two basic options

  • read only: by default every share is read-only, regardless of filesystem permissions,
  • writeable: in order to allow write access you should set writeable = Yes.

This should be enough to solve the problem. But if you'd like to learn more about Samba permissions, like how to set umask, enable guest account or control access for individual users/groups, then read the short tutorial on Samba permissions.

Answer from Adam Byrtek on askubuntu.com
Discussions

Samba write permissions
You do not set up write privilege for Samba, you set up permissions for the user and you do it on the server, how you do this will, to a certain extent, depend on how you are running Samba. It will help if you can post the output of 'testparm -s' from the Samba server. More on reddit.com
🌐 r/linuxquestions
9
1
September 20, 2024
Write permission denied for SMB share - General Support - Unraid
I am unable to write to a public SMB share (share is exported and public). I am able to read from the share. I am authenticating as a guest. The output of smbstatus while authenticated is: Samba version 4.11.4 PID Username Group Machine Protocol Version Encryption Signing ------------------------... More on forums.unraid.net
🌐 forums.unraid.net
August 29, 2021
How to create a Samba share that is writable from Windows without 777 permissions? - Unix & Linux Stack Exchange
Then Windows asks for credentials, but no matter what I enter, it's always denied. What is the correct way to gain write access to Samba shares from a Windows domain computer without granting 777 permissions? More on unix.stackexchange.com
🌐 unix.stackexchange.com
I can access my Samba shared folder but can't write. Permission Denied.
The following is a minimal configuration for a Samba standalone server that only allows guest access: [global] map to guest = Bad User log file = /var/log/samba/%m log level = 1 [guest] # This share allows anonymous (guest) access # without authentication! comment = Shared folder path = /home/Shared read only = no guest ok = yes guest only = yes su systemctl restart smb More on reddit.com
🌐 r/Fedora
4
0
March 4, 2020
🌐
Raspberry Pi Forums
forums.raspberrypi.com › board index › using the raspberry pi › troubleshooting
Cannot get write access on a samba shared drive - Raspberry Pi Forums
November 6, 2023 - I really, really, don't recommend doing thsi though. Change your mount options to include uid=nobody,gid=nogroup. This will allow your Samba guest clients write access but you'll still hit permissions with other Linux users e.g when logged in to the pi directly or over ssh/vnc.
🌐
Unraid
forums.unraid.net › home › unraid os support › general support › write permission denied for smb share
Write permission denied for SMB share - General Support - Unraid
August 29, 2021 - I am unable to write to a public SMB share (share is exported and public). I am able to read from the share. I am authenticating as a guest. The output of smbstatus while authenticated is: Samba version 4.11.4 PID Username Group Machine Protocol Version Encryption Signing ------------------------...
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.)

🌐
Reddit
reddit.com › r/fedora › i can access my samba shared folder but can't write. permission denied.
r/Fedora on Reddit: I can access my Samba shared folder but can't write. Permission Denied.
March 4, 2020 -

I setup a Samba shared folder and I can access it through my other linux laptop (manjaro) but I can't write any changes to it. I get a Permission Denied message.

samba config file

Also I did steps 2/3 from this site to make samba work on Fedora 31.

Anyone know how can I make my shared folder writeable by other users mainly my other linux machine (manjaro)?

Thanks

Find elsewhere
🌐
Raspberry Pi Forums
forums.raspberrypi.com › board index › projects › networking and servers
samba server gives me a permission denied error when connecting - Raspberry Pi Forums
[global] log file = /var/log/s... /home/shares/public/disk1 read only = No create mask = 0660 directory mask = 0770 You then need to create users with 'smbpasswd -a username' , you need to do this as root (or using sudo), you will be prompted for a password (twice...
🌐
Raspberry Pi Forums
forums.raspberrypi.com › board index › using the raspberry pi › troubleshooting
Samba Write Access Denied Windows 10 - Raspberry Pi Forums
I just ran chmod -R g=rwx /media/hdd4tb/shares/torrents/ and that fixed my issue. Thanks for the help. Hmm, if I physically take that hard drive and connect it to another linux machine instead of using samba shares, how do I keep permissions intact if I'm working with the files?
🌐
Linux.org
linux.org › home › forums › server linux › general server
SAMBA permission error. Even the sudoers can't acess the directorys. | Linux.org
July 29, 2021 - Have you configured the firewall on your server to allow in coming traffic for samba from your local network? Click to expand... The [testshare] is working, maybe i made a typo. But if i use the "same" parameters on the other shared folders they dont want to work. For examle: ... [Omichron] comment = Everyone can reach this folder. path = /home/Omichron browseable = yes read only = no create mask = 775 directory mask = 775 write list = @dolgozok This isnt working, i got the same error.
Top answer
1 of 1
10

Note: I'm just guessing here, I'm not a samba guru.

Samba/CIFS, at least the way you're using it here, does not reproduce credentials between the server and the client. Because of the force user directive on the server, all operations are performed as the user erpm on the server. However, because both the client and the server are running a unix system, they auto-negociated the CIFS POSIX extensions. This makes unix permissions appear to work up to a point, but only as far as the server permits, and you've run into a case where what the unix permissions claim and what the server allows differ.

You'll notice that all files appear as user ID 501. That's their uid on the server.

When you try to create or remove a file, this requires write permission on the directory. All access are mapped to a single user on the server, so write permission boils down to whether erpm is allowed to write to that directory on the server. The answer is yes.

When you run touch, it creates the file and then changes its modification time. Changing the modification time of a file requires ownership, and this is tested by the generic filesystem code, on the client side.

If you run strace touch test, you'll notice that then open call (which creates the file) succeeds, then the utimes call (or rather on Linux the utimensat system call) fails to set the times.

This is actually a bit weird because utimes should succeed, since touch calls it with a NULL argument (meaning “set the timestamp to the current time”), and this is supposed to be permitted to any caller that may write to the file, and not only to the owner like setting an arbitrary timestamp. I suspect that utimensat is actually doing a permissions-based check, and determining that the permissions say you can't write to that file, even though the filesystem would allow a write operation regardless of the actual permissions.

The main advantage of the CIFS POSIX extensions when the server side is running with the permissions of a non-root user are to carry over the executable bit, and possibly group ownership. It may be less confusing if you map user ownership to a single client-side user with the forceuid mount option.

🌐
Samba
samba.org › samba › docs › using_samba › ch09.html
Samba
The write list option cannot override Unix permissions. If you've created the share without giving the write-list user write permission on the Unix system, she will be denied write access regardless of the setting of write list.
🌐
LinuxQuestions.org
linuxquestions.org › questions › linux-networking-3 › can't-write-to-samba-share-4175706103
[SOLVED] Can't write to samba share
I have an OpenMediaVault server with Samba shares. I can mount them remotely but I can't write to them. I've wrestled with this problem quite a bit in
🌐
Server Fault
serverfault.com › questions › 1112551 › samba-shared-folder-on-ubuntu-20-04-permission-denied-when-writing-from-windows
samba shared folder on ubuntu 20.04 permission denied when writing from windows 8 machine - Server Fault
October 8, 2022 - I setup a shared samba folder on ubuntu 20.04 It appears on the Windows 8.1 machine on the same subnet but if I try to write to the folder I get a permission denied error
🌐
Super User
superuser.com › questions › 1568771 › lost-write-permission-in-samba-4-5
linux - Lost write permission in Samba 4.5 - Super User
July 15, 2020 - To answer my own question: smbpasswd -a vdr solved my problem. Seems like Samba 4.5 became more strict compared to Samba 4.2.
🌐
Stack Exchange
unix.stackexchange.com › questions › 594368 › samba-write-access-denied
ubuntu - Samba - write access denied - Unix & Linux Stack Exchange
June 22, 2020 - Setup: A single samba share. [myuser] wide links = yes path = /home/myuser public = no writable = yes create mask = 0644 directory mask = 0770 force user = myuser force group = myuser available = yes write list = myuser ... I then browse the share, and authenticate. I try to delete or modify files and I get denied due to access permissions...
🌐
Raspberry Pi Forums
forums.raspberrypi.com › board index › using the raspberry pi › beginners
Samba fileshare Permission Denied help asked (seems to be a common confusion) [Solved] - Raspberry Pi Forums
June 6, 2023 - Did you add the fstab line as instructed to by that guide and using the same mountpoint? If so, you should be able to write to it as root, with sudo, or when logged in to Linux as the user pi. If you can't or if the mount hasn't worked you need to fix that first before worrying about Samba ...