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

linux - Unable to create / edit files as non-root through Samba mount - Stack Overflow
I'm trying to setup a code-server ... mounted samba share. Unfortunately when I try to add a file it gives me an error that I do not have permissions to read/write to that folder. When I try to add files with the same credentials on Windows it does work though. This is the error that VSCode gives me: Unable to write file 'vscode-remote://localhost:8080/home/user/repository/test' (NoPermissions (FileSystemError): Error: EACCES: permission denied, open ... More on stackoverflow.com
๐ŸŒ stackoverflow.com
mount - Samba share permission denied user writing file but still shows - Unix & Linux Stack Exchange
Very strange issue... Samba share on remote: [javaerpm] path = /u/abas/erpm/java force user = erpm guest ok = yes read only = no writeable = yes Mount command on local using r... More on unix.stackexchange.com
๐ŸŒ unix.stackexchange.com
September 24, 2013
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
๐ŸŒ
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 ------------------------...
๐ŸŒ
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.
๐ŸŒ
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...
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.

Find elsewhere
๐ŸŒ
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 ...
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

๐ŸŒ
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
๐ŸŒ
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.
๐ŸŒ
FreedomBox
discuss.freedombox.org โ€บ support
Samba -- permission denied writing to share - Support - FreedomBox Forum
January 31, 2023 - Canโ€™t create file on mounted samba share Steps to Reproduce Hook external ORICO usb3 hard drive enclosure to Olimex HSK Pioneer Freedombox decrypt harddrives blkid -o uuid /dev/sd{a3,b3} cryptsetup open /dev/sda3 uuid-a3 crypsetup open /dev/sdb3 uuid-b3 btrfs device scan /dev/mapper/uuid-a3 /dev/mapper/uuid-b3 mount -L BTROOT /media/root/BTROOT root@freedombox:~# btrfs fi show /media/root/BTROOT/ Label: 'BTROOT' uuid: 5487d18b-bd2f-45c9-b2c7-893d269977c9 Total devices 2 FS bytes used ...
๐ŸŒ
Super User
superuser.com โ€บ questions โ€บ 1023925 โ€บ give-write-permissions-on-samba-shares
Give write permissions on samba shares - Super User
September 1, 2016 - However, as soon as I attempt to ... I get Permission denied errors. However, I only get them for folder1 and folder2, in folder3 everything works perfectly. I can't figure out what prevents me from writing to the other folders. Does anyone have any ideas at all? ... If you have any configuration lines that look like they are simply placed after the blocks, the result may be that the configuration line(s) are actually affecting just the last block. In my actually-working Samba configuration, ...
Top answer
1 of 6
5

Is SELinux active? If it is, then you can make it accessible by setting the type to public_content_t. If samba should be able to write to it, then set the type to public_content_rw_t. Note that if you do the latter, you will also need to tell SELinux about this; my system-config-selinux has a boolean for this: Allow Samba to write files in directories labeled public_content_rw_t

2 of 6
3

There's some additional information you will need to provide to answer this question.

I chown'd the /upload folder to my account 'kevin' and checked that I could create files and folders via the shell.

  • Did you do this chown as root, or as kevin, or as some other account?
  • What is the group currently assigned to the directory?
  • What is the directory's mode? Is the execute bit set for the user and group?

I can browse to the machine from Windows 7, authenticate as 'kevin' and see my home directory share and the upload share but I can't access them.

  • Is your Windows 7 machine a member of the same workgroup as the Samba server?
  • Is the server a member of a domain, is it a domain controller, or is it a stand-alone server? If your Windows 7 machine is in a domain you'll want to consider joining the server to the domain as well. While not necessary, it will help with authentication.
  • What is the security = setting currently at in /etc/samba/smb.conf? If your Samba server is a member of a domain it should probably be security = ads; if your Samba server is stand-alone it should probably be either security = user or security = share.
  • Do you have an entry for client signing = no? (You may need yes instead when connecting with newer Windows clients)
  • Do you have an entry for client use spnego = no? (You may need yes instead when connecting with newer Windows clients)
  • Is winbind running? If your server is not a domain member or a domain controller this may cause a bit of confusion while running; stand-alone servers do not need this service.
๐ŸŒ
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.