It’s not that often I need to create Samba shared directories on my Linux machines, but making public shared directories that don’t require a user login/password is less straightforward that it should be in my opinion The overall purpose of this post is to make my future interactions with Samba significantly less painful.
General Steps In Distros (e.g. Arch, Fedora, & Ubuntu)
When sharing stuff in the home directory, a mounted directory, or directory from a different drive, it is essential to add force user = <username> under the parameters of the respective directory in /etc/samba/smb.conf. For many years in which I’ve been reading tutorials on the internet as well as RTFM of Samba, almost none of them have made it clear that you have to do this; however, ChatGPT included this detail while Bard and Bing did not.
In addition, that user has to be added in Samba via sudo smbpasswd -a <username> with the Samba username matching an existing local username in the host machine.
For some reason, adding force user = <username> is not necessary when sharing other directories under root.
Fedora Specific
Important to change settings in SELinux to allow sharing of directories:
sudo semanage fcontext --add --type "samba_share_t" "<directory>(/.*)?" sudo restorecon -R <directory>
Source: https://docs.fedoraproject.org/en-US/quick-docs/samba/