Join our Newsletter — 33% off our NHI Course
Home› Guides› Samba Active Directory Security Guide: Harden Samba Domain…
Guide Identity & Access Management (IAM)

Samba Active Directory Security Guide: Harden Samba Domain Controllers and File Servers

PDF for newsletter subscribers · free to read online

← All guides
By NHI Mgmt Group, edited by Lalit Choda Updated 14 November 2026 17 min read
On this page

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 = 2 and, after a measured trial, ntlm auth = disabled with nt hash store = never, logging every rejected client first.
  • Turn on audit logging; it is off by default. Raise auth_audit, dsdb_audit and 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 backup archives 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.

ComponentWhere it lives in SambaSecurity relevance
Directory databasesam.ldb and partition files in the Samba private directoryContains password hashes and Kerberos keys; file-system access to this directory is equivalent to Domain Admin
Secretssecrets.ldb and keytabs in the private directoryMachine and trust secrets; restrict to root, include in encrypted backups only
Configurationsmb.conf [global] and share sectionsAll protocol hardening parameters below; place under change control
Administrationsamba-tool locally or against -H ldap://dc, plus Windows RSAT toolsLocal runs against sam.ldb bypass network authentication; restrict root on DCs
KerberosBuilt-in KDC (Heimdal or MIT build)krbtgt key protection, encryption types, delegation
DNSInternal DNS server or BIND9 DLZ backendallow dns updates, zone transfer allow lists
SYSVOLLocal share on each DC, Group Policy filesACLs checked with samba-tool ntacl sysvolcheck; replication is your design
ID mappingidmap.ldb on each DCKeep 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.

ParameterDocumented defaultHardened valueEffect and caveat
server min protocolSMB2_02SMB3 (or SMB2_10 where older members remain)Removes SMB1 and early SMB2 dialects; test printers, scanners and appliances first
server signingdefault (required on an AD DC, disabled otherwise)mandatory on DCs and on file serversStops SMB relay to the server; see the SMB Signing Guide
server smb encryptdefault (if_required)required on shares holding sensitive dataSMB3 encryption per share or globally; clients without SMB3 are refused
ntlm authntlmv2-onlydisabled after a trial, or mschapv2-and-ntlmv2-only where RADIUS needs MSCHAPv2Must be set on every DC to control domain users
lanman authnonoKeep LM authentication off
nt hash storealwaysnever, once ntlm auth = disabled is provenStops storing unsalted NT hashes for user accounts; RC4 Kerberos keys go with them
ldap server require strong authyesyesRequires signed or sealed SASL binds and TLS channel bindings; matches Windows LdapEnforceChannelBinding
kerberos encryption typesallstrongAES only; the legacy value (RC4 only) is to be avoided
restrict anonymous02Blocks anonymous SAMR access and anonymous IPC$ connections
server schannel and server schannel require sealyes and yesyes and yesserver schannel is deprecated; use per-account server require schannel:ACCOUNT = no exceptions only for named legacy members
reject md5 clientsyesyesRefuses netlogon clients that only support MD5-based schannel
allow dns updatessecure onlysecure onlyOnly Kerberos-authenticated dynamic DNS updates
tls enabled plus certificate filesyes (key and certificate files under tls/ in the private directory by default)yes, with tls certfile, tls keyfile, tls cafile from your PKILDAPS 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 listmembers on 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> on for every administrative account, so its credentials cannot be forwarded by a service trusted for delegation.
  • Review delegation settings: samba-tool delegation show lists constrained delegation targets and whether an account is trusted for any service or any protocol. Turn off for-any-service unless a documented application needs it. See the Kerberos Delegation Security Guide.
  • Use authentication policies and silos: recent releases add samba-tool domain auth policy and domain 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 create after 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 create and pso apply) for stricter rules on admins and service accounts. A check password script can 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.

Controlsmb.conf setting or toolWhy
Signing and encryptionserver signing = mandatory; server smb encrypt = required on sensitive sharesIntegrity against relay; confidentiality on untrusted networks
Protocol floorserver min protocol = SMB3 where clients allowRemoves dialects without encryption support
Host restrictionhosts allow and hosts deny per share or globallyLimits which subnets can connect at the SMB layer, in addition to the firewall
Guest accessguest ok = no; restrict anonymous = 2No anonymous browsing or share access
PermissionsWindows ACLs via vfs objects = acl_xattr, managed from Windows or samba-tool ntaclOne permission model, reviewed with the same tools as Windows shares
File access auditingvfs objects = full_audit with selected operations sent to syslogRecords opens, renames and deletes for investigations and ransomware detection
Role separationKeep DCs and file servers on separate hostsLimits 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.

  1. 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.
  2. Secure the sync transport: use SSH with a dedicated key restricted to the rsync command, not root password logins between DCs.
  3. Check ACLs after sync: run samba-tool ntacl sysvolcheck and, where it reports drift, samba-tool ntacl sysvolreset.
  4. Copy idmap.ldb deliberately: copy it from the PDC Emulator when a DC first joins and periodically after, so IDs match across DCs.
  5. Monitor directory replication: schedule samba-tool drs showrepl --summary and alert on failures; run samba-tool dbcheck before upgrades.
  6. Control FSMO moves: use samba-tool fsmo transfer in planned changes and reserve fsmo seize for 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 classLevelWhat it recordsUse
auth_audit / auth_json_audit2 failures, 3 successes, 4 authorisation, 5 anonymousEvery authentication and authorisation on the DC, including NTLM vs KerberosPassword spraying, NTLM usage tracking, impossible logons
dsdb_audit / dsdb_json_auditPer manual pageChanges to sam.ldbUnexpected object or ACL changes
dsdb_group_audit / dsdb_group_json_auditPer manual pageGroup membership changesAlert on privileged group additions
dsdb_password_audit / dsdb_password_json_audit5Password changes and resets, authentication-related attribute changes such as altSecurityIdentitiesAccount takeover, shadow credential style changes
dsdb_transaction_auditPer manual pageDatabase transaction commits and failuresIntegrity 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 -s output diffs.
  • Patch latency: days from a Samba security release to deployment on all DCs.
  • Replication health: days with drs showrepl failures, 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 online copies a running DC's database over the network into a tar file; backup offline backs up local directories with proper locking; backup restore creates a new DC from the archive; backup rename produces 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 dbcheck before and after, upgrade one DC at a time, and confirm replication and authentication logs before moving on.

Implementation roadmap

  1. 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.
  2. 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.
  3. 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.
  4. 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.
  5. 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 = strong and finally nt hash store = never.
  6. 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 areaNIST SP 800-53 Rev 5NIST CSF 2.0ATT&CK techniques addressed
Pinned smb.conf baseline, unused services removedCM-6, CM-7PR.PS-01T1557.001 Name Resolution Poisoning and SMB Relay
Signing, sealing, LDAPS, SMB3 encryptionSC-8PR.DS-02T1557.001, T1021.002 SMB/Windows Admin Shares
Privileged groups, sensitive accounts, auth silosAC-6, IA-2PR.AA-05T1003.006 DCSync
Password policy, PSOs, gMSAs, AES onlyIA-5PR.AA-01T1558.003 Kerberoasting, T1110 Brute Force
Audit classes, central loggingAU-2, AU-12DE.CM-01T1110, T1484.001 Group Policy Modification
Domain backups and restore testsCP-9PR.DS-11Recovery from domain compromise
Security releases on a supported branchSI-2ID.RA-01Exploitation of unpatched services

Common misconfigurations

  • Copied configs from old tutorials: lines such as ntlm auth = yes, server min protocol = NT1 or ldap server require strong auth = no survive from early deployment notes and override secure defaults. Diff testparm -s output 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 sysvolcheck after 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

Related NHI Mgmt Group resources: Active Directory Security Checklist · OpenLDAP Security · SMB Signing Guide · Kerberos Security Guide

PDF for subscribers

Take this guide with you

Every section, table and checklist in one PDF, with links to the sources and related guides. Subscribe to our weekly NHI & AI Identity Journal and we’ll email you a download link.

Free weekly newsletter

Subscribe to the NHI & AI Identity Journal

The latest on NHI and Agentic AI security – articles, research, breaches, news and events every week.

Bonus 33% off our NHI Course when you subscribe.

NHIMG Editorial Note
Researched and written by the NHI Mgmt Group editorial team using AI tools, under the editorial direction of Lalit Choda. Facts are drawn from the sources listed on this page and checked by our automated quality process. Last updated 14 November 2026. Spotted an error? Use our contact page.
NHI Mgmt Group, the independent authority on Non-Human Identity, IAM and Agentic AI security. nhimg.org

PDF Downloads for Newsletter Subscribers

Get the guide

Enter your details and we’ll email you a download link.

The full guide is free to read online. The PDF is a thank you for subscribing.

Fill in all fields marked * and tick the PDF box to continue.