Linux: Samba and SMB - Paiet/Tech-Journal-for-Everything GitHub Wiki

  • Server Message Block (SMB)
    • Proprietary file sharing protocol developed by Microsoft
    • Sometimes referred to as Common Internet File System (CIFS)
    • Samba is an open source implementation of SMB
    • Created by reverse engineering the protocol
    • Not all features are supported, but stable compatibility has been reached
      • File and Printer Sharing
      • RHEL can be an AD domain member
      • Cannot be a domain controller
  • Configure a Samba Server
    1. Install Samba
      • sudo yum install samba samba-client samba-common x. Create user accounts (if authenticating)
      • sudo useradd dpezet
      • sudo groupadd employees
      • sudo usermod -a -G employees dpezet
      • sudo smbpasswd -a dpezet
    2. Create shared folders
      • sudo mkdir -pm 755 /shares/public
      • sudo chown -R nobody:nobody /shares/public/
      • sudo mkdir -m 770 /shares/private
      • sudo chown -R dpezet:employees /shares/private/
    3. Configure the Samba service
      • sudo vi /etc/samba/smb.conf
      • See example config below
    4. Allow Samba in SELinux
      • sudo chcon -t samba_share_t /shares/public/
      • sudo chcon -t samba_share_t /shares/private/
    5. Allow Samba clients through the firewall
      • firewall-cmd --permanent --zone=public --add-service=samba
      • firewall-cmd --reload
    6. Start Samba
      • sudo systemctl enable --now smb.service nmb.service
  • Configure a Samba Client
    1. Places -> Network -> Windows Network

Example smb.conf

[global]
netbios name = FILESERVER
map to guest = bad user
dns proxy = no
security = user
workgroup = WORKGROUP
# Active Directory mode
# security = ADS
# realm = <domain_fqdn>
# password server = <pdc_emulator_fqdn>

[public]
path = /shares/public/
browsable = yes
writable = yes
guest ok = yes
read only = no

[private]
path = /shares/private/
# valid users = <username> <username> ...
valid users = @employees
browsable = yes
writable = yes
guest ok = no
read only = no
⚠️ **GitHub.com Fallback** ⚠️