A Samba Active Directory domain controller holds the same crown jewels as any AD DC, every password-derived key in the domain, and it is configured through one text file and one command line tool that many teams set up once and never revisit. Samba can act as an AD DC (Kerberos KDC, LDAP, DNS, SMB and the AD RPC services in one process tree) and as a domain member file server joined through winbind. This guide covers the customer-side settings that decide how safe both roles are: the smb.conf parameters for SMB, NTLM, LDAP and Kerberos, privileged groups and service accounts, SYSVOL and replication, audit logging, backups and patching. It is written for Linux platform engineers and identity teams running Samba 4.x, and uses parameter and command names from the Samba Team's own manual pages. For general directory protocol depth, see the LDAP Security Deep Dive Guide.
This is an independent guide from NHI Mgmt Group, based on the Samba Team's public documentation as of November 2026. It is not sponsored or reviewed by the Samba Team. Product features change, so confirm settings against the Samba Team's current documentation.
Key takeaways
- Treat every Samba DC as Tier 0. The sam.ldb database and its key material allow forging tickets for the whole domain, so DC hosts, their root accounts, backups and hypervisors need the same protection as the directory itself.
- Keep the secure defaults and write them down. Current releases default to SMB2 or later, NTLMv2 only, required SMB signing on a DC and strong LDAP authentication; pin these values explicitly in smb.conf so an old copied config cannot quietly weaken them.
- Remove legacy protocols with a plan. Use
kerberos encryption types = strong,restrict anonymous = 2and, after a measured trial,ntlm auth = disabledwithnt hash store = never, logging every rejected client first. - Turn on audit logging; it is off by default. Raise
auth_audit,dsdb_auditand the group and password audit classes, emit JSON, and forward to your SIEM from every DC. - Plan SYSVOL, backups and patching yourself. Samba DCs do not replicate SYSVOL with DFS-R, so you choose and secure a sync method, keep encrypted
samba-tool domain backuparchives offline, and track Samba security releases for your supported branch.
How identity and access work in Samba AD
Samba's AD DC implements the Active Directory data model, so the identity concepts are the same as in Windows AD: users, groups, computer accounts, service principal names, Group Policy objects and the built-in privileged groups. What differs is where the controls live.
| Component | Where it lives in Samba | Security relevance |
|---|---|---|
| Directory database | sam.ldb and partition files in the Samba private directory | Contains password hashes and Kerberos keys; file-system access to this directory is equivalent to Domain Admin |
| Secrets | secrets.ldb and keytabs in the private directory | Machine and trust secrets; restrict to root, include in encrypted backups only |
| Configuration | smb.conf [global] and share sections | All protocol hardening parameters below; place under change control |
| Administration | samba-tool locally or against -H ldap://dc, plus Windows RSAT tools | Local runs against sam.ldb bypass network authentication; restrict root on DCs |
| Kerberos | Built-in KDC (Heimdal or MIT build) | krbtgt key protection, encryption types, delegation |
| DNS | Internal DNS server or BIND9 DLZ backend | allow dns updates, zone transfer allow lists |
| SYSVOL | Local share on each DC, Group Policy files | ACLs checked with samba-tool ntacl sysvolcheck; replication is your design |
| ID mapping | idmap.ldb on each DC | Keep consistent across DCs so file ownership maps to the same IDs |
The practical consequence: anyone with root on a Samba DC can read sam.ldb directly, and samba-tool user getpassword run locally can return stored password material for accounts. Root on a DC must therefore be treated as a domain administration privilege, granted through PAM tooling, logged, and limited to named people.
Protocol hardening in smb.conf
The table lists the parameters that matter most on a Samba DC, the default stated in the smb.conf manual page, and the hardened value to aim for. Pin each value explicitly in [global]; a parameter left out silently follows whatever default ships with the next upgrade.
| Parameter | Documented default | Hardened value | Effect and caveat |
|---|---|---|---|
server min protocol | SMB2_02 | SMB3 (or SMB2_10 where older members remain) | Removes SMB1 and early SMB2 dialects; test printers, scanners and appliances first |
server signing | default (required on an AD DC, disabled otherwise) | mandatory on DCs and on file servers | Stops SMB relay to the server; see the SMB Signing Guide |
server smb encrypt | default (if_required) | required on shares holding sensitive data | SMB3 encryption per share or globally; clients without SMB3 are refused |
ntlm auth | ntlmv2-only | disabled after a trial, or mschapv2-and-ntlmv2-only where RADIUS needs MSCHAPv2 | Must be set on every DC to control domain users |
lanman auth | no | no | Keep LM authentication off |
nt hash store | always | never, once ntlm auth = disabled is proven | Stops storing unsalted NT hashes for user accounts; RC4 Kerberos keys go with them |
ldap server require strong auth | yes | yes | Requires signed or sealed SASL binds and TLS channel bindings; matches Windows LdapEnforceChannelBinding |
kerberos encryption types | all | strong | AES only; the legacy value (RC4 only) is to be avoided |
restrict anonymous | 0 | 2 | Blocks anonymous SAMR access and anonymous IPC$ connections |
server schannel and server schannel require seal | yes and yes | yes and yes | server schannel is deprecated; use per-account server require schannel:ACCOUNT = no exceptions only for named legacy members |
reject md5 clients | yes | yes | Refuses netlogon clients that only support MD5-based schannel |
allow dns updates | secure only | secure only | Only Kerberos-authenticated dynamic DNS updates |
tls enabled plus certificate files | yes (key and certificate files under tls/ in the private directory by default) | yes, with tls certfile, tls keyfile, tls cafile from your PKI | LDAPS on 636 and GC SSL on 3269; use a certificate from your PKI so clients can validate it |
Two settings deserve a staged approach. For NTLM, set ntlm auth = disabled on one DC in a test site first, watch authentication audit logs for NTLM failures, and keep nt hash store = always during that trial (the manual page suggests exactly this) so you can roll back by changing one line. Only after the trial, set nt hash store = never: new and changed passwords then stop producing NT hashes, so rolling back later requires password changes. For Kerberos, moving to strong breaks any service whose account only has RC4 keys; find those accounts first. See the NTLM Deprecation and Elimination Guide and the Kerberos RC4 Deprecation guide.
Network exposure
A Samba AD DC listens on 53 (DNS), 88 (Kerberos), 135 (endpoint mapper), 137 to 139 (NetBIOS), 389 (LDAP), 445 (SMB), 464 (kpasswd), 636 (LDAPS), 3268 and 3269 (Global Catalog), 123/udp if NTP signing is configured, and the dynamic RPC range 49152 to 65535 (set by rpc server dynamic port range). Restrict these with host and network firewalls to client subnets and other DCs, block them entirely from the internet, and drop NetBIOS (137 to 139) where no legacy client needs it. Remove services you do not use from server services, for example -nbt or -wrepl when NetBIOS and WINS are not required.
Privileged groups, delegation and service accounts
- Built-in privileged groups: Domain Admins, Enterprise Admins, Schema Admins, Administrators and the operator groups behave as in Windows AD. Review membership with
samba-tool group listmemberson a schedule and alert on change (see audit logging below). Keep Schema Admins and Enterprise Admins empty except during planned changes. - Protect admin accounts from delegation: set UF_NOT_DELEGATED with
samba-tool user sensitive <account> onfor every administrative account, so its credentials cannot be forwarded by a service trusted for delegation. - Review delegation settings:
samba-tool delegation showlists constrained delegation targets and whether an account is trusted for any service or any protocol. Turn offfor-any-serviceunless a documented application needs it. See the Kerberos Delegation Security Guide. - Use authentication policies and silos: recent releases add
samba-tool domain auth policyanddomain auth silo, which restrict where privileged users may authenticate from and to. Use them to confine Tier 0 accounts to DCs and admin workstations. - Service accounts: prefer group managed service accounts, created with
samba-tool service-account createafter a KDS root key exists (samba-tool domain kds root-key create), so passwords rotate automatically on the managed password interval. Where a classic user account must hold an SPN, give it a long random password and a fine-grained password policy. See the How to build a service account inventory from Active Directory walkthrough. - Password policy: set domain defaults with
samba-tool domain passwordsettings set(length, complexity, history, lockout) and use Password Settings Objects (passwordsettings pso createandpso apply) for stricter rules on admins and service accounts. Acheck password scriptcan enforce a banned-password list; it receives the candidate password on standard input, so protect the script and its logs.
Where identity fits
Machine accounts, gMSAs, keytabs exported with samba-tool domain exportkeytab and the credentials used by backup and monitoring tools are non-human identities with domain reach. A keytab holding the keys of a privileged account is as sensitive as its password: store exported keytabs root-only, track them in the NHI inventory, and rotate the account when a keytab leaves its host. See the OpenLDAP Security guide for the comparable discipline around directory bind and replication identities.
Domain member file servers
File servers joined to the domain run smbd with winbind and are where most user data lives. The DC hardening above protects authentication; these settings protect the data path.
| Control | smb.conf setting or tool | Why |
|---|---|---|
| Signing and encryption | server signing = mandatory; server smb encrypt = required on sensitive shares | Integrity against relay; confidentiality on untrusted networks |
| Protocol floor | server min protocol = SMB3 where clients allow | Removes dialects without encryption support |
| Host restriction | hosts allow and hosts deny per share or globally | Limits which subnets can connect at the SMB layer, in addition to the firewall |
| Guest access | guest ok = no; restrict anonymous = 2 | No anonymous browsing or share access |
| Permissions | Windows ACLs via vfs objects = acl_xattr, managed from Windows or samba-tool ntacl | One permission model, reviewed with the same tools as Windows shares |
| File access auditing | vfs objects = full_audit with selected operations sent to syslog | Records opens, renames and deletes for investigations and ransomware detection |
| Role separation | Keep DCs and file servers on separate hosts | Limits the number of users with any reason to reach a DC, and keeps Tier 0 small |
SYSVOL, replication and FSMO roles
Samba does not support SYSVOL replication with DFS-R (or the older FRS). The Samba wiki documents alternatives: one-way rsync from the PDC Emulator, bidirectional rsync with Unison or osync, and robocopy from a Samba DC to Windows DCs. Whichever you choose, the sync job runs as a privileged identity that can write Group Policy files on every DC, which makes it a path to T1484.001 Group Policy Modification.
- Make one DC authoritative: edit GPOs only against the PDC Emulator (find it with
samba-tool fsmo show) and sync outwards, so a compromised secondary DC cannot push policy back. - Secure the sync transport: use SSH with a dedicated key restricted to the rsync command, not root password logins between DCs.
- Check ACLs after sync: run
samba-tool ntacl sysvolcheckand, where it reports drift,samba-tool ntacl sysvolreset. - Copy idmap.ldb deliberately: copy it from the PDC Emulator when a DC first joins and periodically after, so IDs match across DCs.
- Monitor directory replication: schedule
samba-tool drs showrepl --summaryand alert on failures; runsamba-tool dbcheckbefore upgrades. - Control FSMO moves: use
samba-tool fsmo transferin planned changes and reservefsmo seizefor documented recovery, because a seized role on a DC that later returns causes conflicts.
Directory replication rights are themselves a target: an account with replication permissions can request password data from a DC, the technique tracked as T1003.006 DCSync. Review who holds replication rights on the domain root with samba-tool dsacl get and keep the list to DCs.
Logging and detection
Samba's authentication and directory audit classes are off at the default log level. The Samba wiki's starting point is log level = 1 auth_audit:3 auth_json_audit:3, which logs failed and successful authentication. For a DC, extend it to directory changes and use the event notification parameters (all default no) if you consume events from the message bus.
| Debug class | Level | What it records | Use |
|---|---|---|---|
auth_audit / auth_json_audit | 2 failures, 3 successes, 4 authorisation, 5 anonymous | Every authentication and authorisation on the DC, including NTLM vs Kerberos | Password spraying, NTLM usage tracking, impossible logons |
dsdb_audit / dsdb_json_audit | Per manual page | Changes to sam.ldb | Unexpected object or ACL changes |
dsdb_group_audit / dsdb_group_json_audit | Per manual page | Group membership changes | Alert on privileged group additions |
dsdb_password_audit / dsdb_password_json_audit | 5 | Password changes and resets, authentication-related attribute changes such as altSecurityIdentities | Account takeover, shadow credential style changes |
dsdb_transaction_audit | Per manual page | Database transaction commits and failures | Integrity and replication troubleshooting |
Logs stay on the DC where the event happened, so configure every DC and forward through syslog (logging, syslog and syslog only parameters) to a central collector. JSON output needs a Samba build with jansson; check with smbd -b | grep HAVE_JSON_OBJECT. Detection priorities: bursts of auth_audit failures across many accounts (T1110 Brute Force), many service ticket requests for SPN accounts from one client (T1558.003 Kerberoasting), NTLM authentications after your cut-off date, privileged group changes, and new SPNs or delegation flags. See the Active Directory Security Monitoring and Event IDs Guide for the matching Windows event logic when you run mixed DCs.
Metrics that show it is working
- NTLM share: percentage of successful authentications using NTLM, trending to zero before
ntlm auth = disabled. - Privileged membership drift: unapproved changes to Tier 0 groups per month (target zero).
- Configuration conformance: DCs whose smb.conf matches the pinned baseline, checked with
testparm -soutput diffs. - Patch latency: days from a Samba security release to deployment on all DCs.
- Replication health: days with
drs showreplfailures, and SYSVOL ACL drift findings. - Restore readiness: date of the last successful test restore from a domain backup.
Backup, recovery and patching
- Back up with samba-tool:
samba-tool domain backup onlinecopies a running DC's database over the network into a tar file;backup offlinebacks up local directories with proper locking;backup restorecreates a new DC from the archive;backup renameproduces a renamed copy for lab use. - Protect backup archives as Tier 0: a domain backup contains every key in the domain. Encrypt archives at rest, store a copy offline or immutable, and restrict restore rights. See the Active Directory Forest Recovery Runbook Template for the recovery sequence.
- Test restores in isolation: restore into an isolated network so a restored DC never replicates stale data into production.
- Patch on a supported branch: the Samba Team publishes security releases and per-issue announcements on its security updates page. Subscribe to it or to your distribution's security feed, stay on a branch that still receives security fixes, and apply vendor security updates promptly to every DC and file server.
- Change control for upgrades: run
samba-tool dbcheckbefore and after, upgrade one DC at a time, and confirm replication and authentication logs before moving on.
Implementation roadmap
- Inventory (week 1): list every DC and file server, Samba version and branch support status, current smb.conf (
testparm -s), FSMO holders, privileged group members, SPN accounts and delegation settings. - Turn on audit logging (week 1 to 2): enable the auth and dsdb audit classes on all DCs and forward to the SIEM, so later changes can be measured.
- Pin the baseline (week 2 to 3): write the hardened
[global]section, apply it to one DC, run regression tests for logons, Group Policy, LDAP applications and DNS updates, then roll to the rest. Keep the previous smb.conf for a one-line rollback. - Tighten accounts (week 3 to 6): mark admin accounts sensitive, remove unneeded delegation, move service accounts to gMSAs, apply PSOs and authentication policies to Tier 0.
- Retire legacy protocols (month 2 to 4): drive NTLM and RC4 usage to zero using the logs, then set
ntlm auth = disabled,kerberos encryption types = strongand finallynt hash store = never. - Prove recovery (quarterly): take encrypted domain backups, run an isolated restore test and record the result.
Small organisations with one or two DCs can compress this into a few weeks but should never skip the second DC: a single Samba DC with no tested backup is a single point of failure for every logon. Larger estates with mixed Windows and Samba DCs should align settings with the Windows equivalents (LdapEnforceChannelBinding, NTLM restriction policies, SMB signing GPOs) so behaviour does not depend on which DC a client reaches.
Framework mapping
| Control area | NIST SP 800-53 Rev 5 | NIST CSF 2.0 | ATT&CK techniques addressed |
|---|---|---|---|
| Pinned smb.conf baseline, unused services removed | CM-6, CM-7 | PR.PS-01 | T1557.001 Name Resolution Poisoning and SMB Relay |
| Signing, sealing, LDAPS, SMB3 encryption | SC-8 | PR.DS-02 | T1557.001, T1021.002 SMB/Windows Admin Shares |
| Privileged groups, sensitive accounts, auth silos | AC-6, IA-2 | PR.AA-05 | T1003.006 DCSync |
| Password policy, PSOs, gMSAs, AES only | IA-5 | PR.AA-01 | T1558.003 Kerberoasting, T1110 Brute Force |
| Audit classes, central logging | AU-2, AU-12 | DE.CM-01 | T1110, T1484.001 Group Policy Modification |
| Domain backups and restore tests | CP-9 | PR.DS-11 | Recovery from domain compromise |
| Security releases on a supported branch | SI-2 | ID.RA-01 | Exploitation of unpatched services |
Common misconfigurations
- Copied configs from old tutorials: lines such as
ntlm auth = yes,server min protocol = NT1orldap server require strong auth = nosurvive from early deployment notes and override secure defaults. Difftestparm -soutput against your baseline. - Self-signed or unmanaged TLS certificates: clients that cannot validate the DC certificate are often configured to skip validation, which removes the protection LDAPS was meant to add.
- Root as the real admin model: shared root passwords on DCs mean every root user is a Domain Admin with no audit trail. Use named accounts, sudo logging and PAM.
- Unprotected SYSVOL sync: passwordless root SSH between all DCs, or bidirectional sync from every DC, lets one compromised DC rewrite Group Policy everywhere.
- Audit logging never enabled: with default log levels there is no record of authentication failures or group changes when an investigation starts.
- Backups stored beside the DC: domain backup tar files on the same host or a writable share give an attacker every key in one file.
Practitioner checklist
- Inventory every Samba DC and file server with version, branch support status and FSMO roles.
- Pin hardened values in
[global]: SMB3 floor, mandatory signing, strong LDAP auth, AES-only Kerberos,restrict anonymous = 2. - Install a TLS certificate from your PKI for LDAPS and Global Catalog SSL.
- Firewall DC ports to client subnets and peer DCs; remove unused services.
- Mark admin accounts sensitive, review delegation, and apply PSOs and authentication silos to Tier 0.
- Move service accounts to gMSAs and track exported keytabs as non-human identities.
- Enable auth and dsdb audit classes with JSON output on every DC and forward to the SIEM.
- Secure SYSVOL sync from the PDC Emulator and run
ntacl sysvolcheckafter each sync. - Take encrypted, offline domain backups and test restores in isolation each quarter.
- Track Samba security releases and patch all DCs within your agreed window.
Standards and references
- Samba Team: smb.conf manual page
- Samba Team: samba-tool manual page
- Samba Team: Security updates and information
- Samba Wiki: Samba AD DC Port Usage
- Samba Wiki: SysVol replication (DFS-R)
- Samba Wiki: Setting up Audit Logging
- NIST: SP 800-53 Rev. 5 Security and Privacy Controls
- MITRE ATT&CK: T1003.006 DCSync
Related NHI Mgmt Group resources: Active Directory Security Checklist · OpenLDAP Security · SMB Signing Guide · Kerberos Security Guide