Setup Anonymous Samba Share on RHEL/CentOS
Anonymous or guest shares allow users to access shared directories without authentication. This setup is useful for public access within a trusted network.
Create a public directory with full access permissions:
mkdir /PublicSet open permissions for read, write, and execute access:
chmod 777 /Public/Or recursively apply to all contents inside:
chmod -R 777 /Public/Verify the directory exists and has correct permissions:
ls -lh / | grep PublicSet ownership to the nobody user and group:
chown -R nobody:nobody /Public/Edit the Samba configuration file:
nano /etc/samba/smb.confAppend or modify the following share definition:
[Public]
path = /Public
writable = yes
guest ok = yes
guest only = yes
read only = no
create mode = 0777
directory mode = 0777
force user = nobody- Enables guest-only access
- Allows full read/write/delete capabilities
- Forces all operations as the
nobodyuser
Apply the configuration by restarting the Samba service:
systemctl restart smb.serviceCheck the list of available shares on the Samba server:
smbclient -L 192.168.112.145Try accessing the public share anonymously:
smbclient //192.168.1.25/Public/Explicitly use guest access with no credentials:
smbclient -L 192.168.112.145 -U "" -NOr connect directly to the public share as a guest:
smbclient //192.168.112.145/Public -U "" -NAnother equivalent form:
smbclient -U "" //192.168.1.27/Public -NHere's an extended smb.conf snippet with additional shares:
mkdir /opt/data
mkdir /backupnano /etc/samba/smb.conf[data]
comment = Data
path = /opt/data
writable = yes
[backup]
comment = Server Backup
path = /backup
writable = yes
valid users = smb-user1, armour
[Public]
path = /Public
writable = yes
guest ok = yes
guest only = yes
read only = no
create mode = 0777
directory mode = 0777
force user = nobodyMake sure the directories /opt/data and /backup exist with proper ownership and permissions for listed users.
Restart Samba after changes:
systemctl restart smb.serviceAnonymous shares should only be used in trusted networks.
Avoid enabling guest access on internet-facing systems or in environments where data sensitivity is a concern.