Skip to content

How to Configure Samba Guest and Home Shares on AlmaLinux, Rocky Linux and RHEL

Updated 2 min read

Updated: 28 September 2026 · Applies to: Samba 4.23 on AlmaLinux and Rocky Linux 9 and 10 and RHEL 9 and 10 (SELinux and firewalld)

This guide adds two common kinds of Samba share on AlmaLinux, Rocky Linux and RHEL: a read-only public folder that anyone on your network can open without a password, and a private home folder for each user. For the basic setup of a password-protected group share, see the beginners guide to Samba. We tested this configuration with Samba 4.23.5 on AlmaLinux 9.

1. Install

dnf install samba samba-client
systemctl enable --now smb

2. Configure the shares

Edit /etc/samba/smb.conf:

[global]
   workgroup = WORKGROUP
   map to guest = Bad User
   hosts allow = 127.0.0.1 192.168.1.0/24

[public]
   path = /srv/samba/public
   guest ok = yes
   read only = yes
   browseable = yes

[homes]
   comment = Home folders
   browseable = no
   read only = no
   valid users = %S
  • map to guest = Bad User: a login with an unknown user name is treated as a guest, which is what makes the public share open without a password.
  • [homes] is a special share: each user who logs in sees a share with their own name, pointing to their home folder. valid users = %S stops users from opening each other's folders.

3. Create the public folder

mkdir -p /srv/samba/public
chmod 755 /srv/samba/public

Copy the files you want to publish into it.

4. SELinux

semanage fcontext -a -t samba_share_t "/srv/samba/public(/.*)?"
restorecon -Rv /srv/samba/public
setsebool -P samba_enable_home_dirs on

The first two commands label the public folder; the boolean allows Samba to share home folders.

5. Users, firewall and check

smbpasswd -a alice                     # a Samba password for each user of [homes]
firewall-cmd --permanent --add-rich-rule='rule family="ipv4" source address="192.168.1.0/24" service name="samba" accept'
firewall-cmd --reload
testparm
systemctl restart smb

6. Test

smbclient -L //localhost -N                 # list shares as a guest
smbclient //localhost/public -N -c 'ls'     # open the public share without a password
smbclient //localhost/alice -U alice        # a home share

The home shares do not appear in the list (browseable = no), but they open by name.

Security

Guest shares are only suitable on a trusted local network. Never allow Samba through a firewall to the internet, and keep public shares read-only.

Official documentation: smb.conf manual and Using Samba as a server (Red Hat).

Was this answer helpful?

Still stuck? Open a ticket