Skip to main content

Using AD as an auth source for logins and samba

(2026-11-09)

Start with Ubuntu LTS 24 minimal + std newvm

dhcp clients allegedly don't get a proper zone suffix:

netplan set network.ethernets.eth0.dhcp4-overrides.use-domains=false
netplan set network.ethernets.eth0.nameservers.search='[corp.myco.com]'
netplan apply

Set hostname:

hostnamectl set-hostname dm-ub-24.corp.myco.com

Install packages:

apt update
apt install -y sssd-ad sssd-tools samba smbclient winbind libpam-sss libnss-sss realmd adcli krb5-user winbind libnss-winbind libpam-winbind samba-dsdb-modules

/etc/samba/smb.conf:

[global]
   kerberos method = secrets and keytab
   netbios name = DM-UB-24
   netbios scope =
   disable netbios = yes
   workgroup = CORP
   security = ads
   realm = CORP.MYCO.COM

   # Identity Mapping Strategy (Standardized)
   idmap config * : backend = tdb
   idmap config * : range = 3000-7999
   idmap config CORP : backend = sss
   idmap config CORP : range = 100000-2147483647

   winbind use default domain = yes
   map acl inherit = yes
   store dos attributes = yes
   vfs objects = acl_xattr
   template shell = /bin/bash

   # No
#  winbind enum users = yes
#  winbind enum groups = yes

[shared]
   comment = AD Authenticated Share
   path = /srv/samba/shared
   browsable = yes
   read only = no
   inherit permissions = yes

Check smb.conf:

   testparm -s

/etc/sssd/sssd.conf:

[sssd]
services = nss, pam
config_file_version = 2
domains = corp.myco.com

[domain/corp.myco.com]
id_provider = ad
auth_provider = ad
access_provider = ad
chpass_provider = ad

# Match the algorithmic RID mapping behavior of Samba
ldap_id_mapping = true
use_fully_qualified_names = false
fallback_homedir = /home/%u
default_shell = /bin/bash

Domain join:

kinit my.user.sa ; klist -k
net ads join -U my.user.sa

Start sssd:

chmod 600 /etc/sssd/sssd.conf 
systemctl restart sssd

/etc/nsswitch.conf, update these lines:

passwd:         files winbind sss systemd
group:          files winbind sss systemd

Auto-homedir:

pam-auth-update --enable mkhomedir

Start daemons:

for I in sssd winbind smbd nmbd; do
    systemctl stop $I
	systemctl enable --now $I
done

Make share:

mkdir -p /srv/samba/shared 
chown root:"Domain Users" /srv/samba/shared 
chmod 2770 /srv/samba/shared

Tests:

klist -k
wbinfo -t
# these next two should produce the same uid
getent passwd my.user
wbinfo --sid-to-uid=`wbinfo --name-to-sid="my.user" | awk '{print $1}'`