The Handbook

    Theme
    • Guides
        • Check a system before installing FreeBSD
        • Orient a Linux administrator on FreeBSD
        • Supported FreeBSD releases
        • Choose a FreeBSD documentation and support channel
        • Move files safely without GNU mv -t
        • Update and Upgrade FreeBSD
        • Upgrade 14.4 or 15.0 to FreeBSD 15.1
        • Choose packages, ports, or poudriere
        • Choose the quarterly or latest package branch
        • Choose a FreeBSD download or package mirror
        • Make a system setting persistent
        • Run a command from cron reliably
        • Configure locale, keyboard, and time zone
        • Configure a serial console for recovery
        • Choose a custom kernel, module, or loader setting
        • Run a Linux binary with the compatibility layer
        • Check desktop and laptop hardware before installation
        • Choose and check a graphics driver
        • Choose Xorg or Wayland
        • Build a maintainable desktop baseline
        • Install and check a desktop browser
        • Check laptop Wi-Fi, power, and suspend
        • Check multimedia readiness
        • Choose and configure a printing stack
        • Run Windows applications with Wine
        • Snapshot and replicate a ZFS dataset
        • Choose a filesystem and storage layout
        • Operate ZFS without losing the recovery path
        • Restore files from a ZFS snapshot
        • Find what is using ZFS space
        • Grow a ZFS virtual disk
        • Read ZFS pool health and run a scrub
        • Replace a failed device in a ZFS mirror
        • Replicate a ZFS dataset over SSH
        • Change PF safely on a remote host
        • Configure a narrow WireGuard tunnel
        • Share a directory with NFS
        • Share files with a named Samba account
        • Plan a FreeBSD home server
        • Choose a mail server or an outgoing relay
        • Publish a network service safely
        • Choose a jail network model
        • Choose native jails or a jail manager
        • Choose a jail or a bhyve virtual machine
        • Establish a FreeBSD security baseline
        • Choose a MAC policy
        • Audit security-relevant activity
        • Start a DTrace performance investigation
    • Integrations
        • Create a first jail with Bastille
        • Compare jail managers and OCI tooling
        • Publish a Bastille service through PF
        • Mount a ZFS dataset in a Bastille jail
        • Update and upgrade Bastille jails
        • Back up and restore a Bastille jail
        • Prepare bhyve and vm-bhyve
        • Choose NFS or Samba for file sharing
        • Choose ZFS backup automation
        • Build a first signed poudriere repository
        • Operate a signed poudriere repository
        • Manage FreeBSD configuration with Ansible or Salt
        • Run Motion with webcamd on FreeBSD
        • Design a reverse proxy, certificates, and monitoring
    • FAQ
      • Troubleshooting
          • Recover an interrupted freebsd-update run
          • Resolve a package repository or ABI mismatch
          • Diagnose the FreeBSD boot path
          • Recover with a ZFS boot environment
          • Diagnose DNS, routing, and firewall paths
          • Diagnose network mbuf exhaustion
          • Bind a service to a low port without running it as root
          • Diagnose a service that will not start
          • Diagnose audio output or input
          • Diagnose webcamd, cuse, and a webcam
          • Fix USB device permissions without opening every device
      • About this handbook
      • Synopsis
      • Install an available Samba package
      • Create the account and directory
      • Configure one share
      • Start and inspect the service
      • Check from another system
      • Check persistence and retain backups
      • Primary references

      Share files with a named Samba account

      Last reviewed
      7 November 2026
      Applies to
      15.1-RELEASE
      Tested on
      15.1-RELEASE

      Synopsis #

      A standalone Samba server can expose one directory to named users without an Active Directory deployment. The account must exist on FreeBSD and in Samba’s password database. SMB authentication does not override the directory’s UNIX permissions.

      Use a trusted private network or VPN, and allow TCP 445 only from the intended clients. The example server address 192.0.2.10 must be replaced with the actual private address. This procedure does not enable legacy NetBIOS discovery, guest access, printer sharing, or domain membership.

      Install an available Samba package #

      Check available package versions before selecting one:

      $ pkg search -S name -x '^samba[0-9]+$'
      # pkg install samba424
      

      The example uses Samba 4.24. Select a maintained version available from the configured package branch rather than mixing branches for one dependency.

      Create the account and directory #

      If the intended user already exists, inspect it with id shareuser and use its actual group. Otherwise, create a dedicated account without an interactive login shell:

      # pw useradd -n shareuser -m -s /usr/sbin/nologin
      

      For a new ZFS dataset on pool zroot:

      # zfs create -o mountpoint=/srv/smbshare zroot/smbshare
      # chown shareuser:shareuser /srv/smbshare
      # chmod 2770 /srv/smbshare
      

      Substitute the actual pool. The set-group-ID directory bit keeps new entries associated with the directory’s group. Do not recursively change ownership of an existing data tree without reviewing its current access requirements.

      Configure one share #

      Create /usr/local/etc/smb4.conf on a new standalone server, or merge these settings into an existing configuration:

      [global]
          server role = standalone server
          map to guest = Never
          interfaces = lo0 em0
          bind interfaces only = yes
          smb ports = 445
          disable netbios = yes
          load printers = no
      
      [files]
          path = /srv/smbshare
          read only = no
          guest ok = no
          valid users = shareuser
          create mask = 0640
          directory mask = 0750
      

      Replace em0 with the actual private-facing interface from ifconfig -a. Keep the server’s address configured before the service starts. Interface binding limits listeners; it does not replace client filtering in the firewall.

      Add the Samba password interactively and validate configuration:

      # smbpasswd -a shareuser
      # testparm -s
      

      The SMB password is separate from the account’s UNIX password. Do not put it in a command argument or enable an empty password to avoid the prompt.

      Start and inspect the service #

      # sysrc samba_server_enable=YES nmbd_enable=NO winbindd_enable=NO
      # service samba_server start
      # service samba_server status
      # sockstat -4 -6 -l
      

      Confirm that smbd listens on TCP 445 at the intended address. A service-start message alone does not prove that a listener is ready. Do not enable nmbd or winbindd unless the selected deployment needs their separate roles.

      Check from another system #

      On a FreeBSD client with Samba’s smbclient installed, create a small input file:

      $ printf 'SMB file check\n' > /tmp/smb-source
      $ smbclient -s /dev/null //192.0.2.10/files -U shareuser -c 'mkdir check; put /tmp/smb-source check/payload; rename check/payload check/renamed; get check/renamed /tmp/smb-result; ls check/*'
      $ cmp /tmp/smb-source /tmp/smb-result
      

      Enter the SMB password when prompted. -s /dev/null selects default client settings for a client without an existing Samba configuration; omit it when site-specific client policy must be retained.

      On the server, inspect the created file:

      # stat -f '%Su:%Sg %Lp' /srv/smbshare/check/renamed
      

      Confirm the expected owner, group, and permissions. Then remove the temporary directory from the client:

      $ smbclient -s /dev/null //192.0.2.10/files -U shareuser -c 'del check/renamed; rmdir check'
      

      An anonymous attempt should fail:

      $ smbclient -s /dev/null //192.0.2.10/files -N -U '%' -c ls
      

      Repeat the named login with an intentionally incorrect password and confirm that it is rejected. If authentication succeeds but file operations fail, inspect filesystem ownership and the share’s authorization rather than broadening access to everyone.

      Check persistence and retain backups #

      After a controlled server restart or reboot, repeat the listener and client checks. Preserve /usr/local/etc/smb4.conf and the Samba account databases with an appropriate backup procedure, as well as the shared data. A data snapshot alone does not recreate SMB identities.

      See NFS or Samba for protocol selection and ZFS file recovery for recovering damaged data. A writable share remains an access path, not an independent backup.

      Primary references #

      • FreeBSD Handbook: Samba
      • Samba smb.conf(5)
      • Samba smbpasswd(8)
      • Samba smbclient(1)
      • Samba testparm(1)

      Independent documentation. Not affiliated with or endorsed by the FreeBSD Project or the FreeBSD Foundation.

      Report a bug
      • Synopsis
      • Install an available Samba package
      • Create the account and directory
      • Configure one share
      • Start and inspect the service
      • Check from another system
      • Check persistence and retain backups
      • Primary references