1.5. Setting up Samba as an AD domain member server
If you are running an AD or NT4 domain, use Samba to add your Red Hat Enterprise Linux server as a member to the domain.
This helps you to gain the following:
- Access domain resources on other domain members
-
Authenticate domain users to local services, such as
sshd - Share directories and printers hosted on the server to act as a file and print server
1.5.1. Joining a RHEL system to an AD domain 링크 복사링크가 클립보드에 복사되었습니다!
Samba Winbind is an alternative to the System Security Services Daemon (SSSD) for connecting a Red Hat Enterprise Linux (RHEL) system with Active Directory (AD). You can join a RHEL system to an AD domain by using realmd to configure Samba Winbind. For more information see, the realm(8) man page on your system.
Procedure
If your AD requires the deprecated RC4 encryption type for Kerberos authentication, enable support for these ciphers in RHEL:
# update-crypto-policies --set DEFAULT:AD-SUPPORTInstall the following packages:
# dnf install realmd oddjob-mkhomedir oddjob samba-winbind-clients \ samba-winbind samba-common-tools samba-winbind-krb5-locator krb5-workstationTo share directories or printers on the domain member, install the
sambapackage:# dnf install sambaBackup the existing
/etc/samba/smb.confSamba configuration file:# mv /etc/samba/smb.conf /etc/samba/smb.conf.bakJoin the domain. For example, to join a domain named
ad.example.com:# realm join --membership-software=samba --client-software=winbind ad.example.comUsing the previous command, the
realmutility automatically:-
Creates a
/etc/samba/smb.conffile for a membership in thead.example.comdomain -
Adds the
winbindmodule for user and group lookups to the/etc/nsswitch.conffile -
Updates the Pluggable Authentication Module (PAM) configuration files in the
/etc/pam.d/directory -
Starts the
winbindservice and enables the service to start when the system boots
-
Creates a
Optional: Set an alternative ID mapping back end or customized ID mapping settings in the
/etc/samba/smb.conffile.For details, see Understanding and configuring Samba ID mapping.
Edit the
/etc/krb5.conffile and add the following section:[plugins] localauth = { module = winbind:/usr/lib64/samba/krb5/winbind_krb5_localauth.so enable_only = winbind }Verify that the
winbindservice is running:# systemctl status winbind ... Active: active (running) since Tue 2018-11-06 19:10:40 CET; 15s ago중요To enable Samba to query domain user and group information, the
winbindservice must be running before you startsmb.If you installed the
sambapackage to share directories and printers, enable and start thesmbservice:# systemctl enable --now smb
Verification
Display an AD user’s details, such as the AD administrator account in the AD domain:
# getent passwd "AD\administrator" AD\administrator:*:10000:10000::/home/administrator@AD:/bin/bashQuery the members of the domain users group in the AD domain:
# getent group "AD\Domain Users" AD\domain users:x:10000:user1,user2Optional: Verify that you can use domain users and groups when you set permissions on files and directories. For example, to set the owner of the
/srv/samba/example.txtfile toAD\administratorand the group toAD\Domain Users:# chown "AD\administrator":"AD\Domain Users" /srv/samba/example.txtVerify that Kerberos authentication works as expected:
On the AD domain member, obtain a ticket for the
administrator@AD.EXAMPLE.COMprincipal:# kinit administrator@AD.EXAMPLE.COMDisplay the cached Kerberos ticket:
# klist Ticket cache: KCM:0 Default principal: administrator@AD.EXAMPLE.COM Valid starting Expires Service principal 01.11.2018 10:00:00 01.11.2018 20:00:00 krbtgt/AD.EXAMPLE.COM@AD.EXAMPLE.COM renew until 08.11.2018 05:00:00
Display the available domains:
# wbinfo --all-domains BUILTIN SAMBA-SERVER AD
If you do not want to use the deprecated RC4 ciphers, you can enable the AES encryption type in AD. See Enabling the AES encryption type in Active Directory using a GPO.
1.5.2. Using the local authorization plug-in for MIT Kerberos 링크 복사링크가 클립보드에 복사되었습니다!
The winbind service provides {AD} users to the domain member. In certain situations, administrators want to enable domain users to authenticate to local services, such as an SSH server, which are running on the domain member. When using Kerberos to authenticate the domain users, enable the winbind_krb5_localauth plug-in to correctly map Kerberos principals to {AD} accounts through the winbind service.
For example, if the sAMAccountName attribute of an {AD} user is set to EXAMPLE and the user tries to log with the user name lowercase, Kerberos returns the user name in upper case. As a consequence, the entries do not match and authentication fails.
Using the winbind_krb5_localauth plug-in, the account names are mapped correctly. Note that this only applies to GSSAPI authentication and not for getting the initial ticket granting ticket (TGT).
Prerequisites
- Samba is configured as a member of an {AD}.
- Red Hat Enterprise Linux authenticates log in attempts against {AD}.
-
The
winbindservice is running.
Procedure
Edit the
/etc/krb5.conffile and add the following section:[plugins] localauth = { module = winbind:/usr/lib64/samba/krb5/winbind_krb5_localauth.so enable_only = winbind }For more information, see the
winbind_krb5_localauth(8)man page on your system.
1.5.3. Enabling certificate auto-enrollment on a Samba client 링크 복사링크가 클립보드에 복사되었습니다!
Certificate auto-enrollment is a function of the Active Directory (AD) Certificate Services. This feature enables users and devices enrollment for certificates without user interaction. Administrators can use certificates issued by the AD certificate authority (CA) in local services without manually monitor and renew certificates, which prevents disruptive outages.
If an AD provides a certificate authority (CA) and a RHEL host is a member of the AD, you can enable certificate auto-enrollment on the RHEL host. Samba then applies the auto-enrollment group policy from AD, and configures the certmonger service to request and manage certificates.
Prerequisites
- Samba is configured as a member of an AD.
A Windows server in the AD has the Active Directory Certificate Services server role with the following services installed:
- Certificate Authority
- Certificate Enrollment
- Policy Web Service
- Internet Information Services (ISS) is configured to provide the certificate auto-enrollment feature over HTTPS.
- ISS uses a certificate issued by the AD CA.
- The Certificate Enrollment service supports Kerberos Authentication.
- A group policy object (GPO) for certificate auto-enrollment is configured in AD.
Procedure
Install the
samba-gpupdatepackage:# dnf install samba-gpupdateAppend the following settings to the
/etc/samba/smb.conffile:kerberos method = secrets and keytab sync machine password to keytab = "/etc/krb5.keytab:account_name:sync_spns:spn_prefixes=host:sync_kvno:machine_password", "/etc/samba/cepces.keytab:account_name:machine_password" apply group policies = yesThe settings specified in the Samba configuration include the following configuration:
kerberos method = secrets and keytab-
Configures Samba to use the
/var/lib/samba/private/secrets.tdbfile first to verify Kerberos tickets and then the/etc/krb5.keytabfile. sync machine password to keytab = <list_of_keytab_files_and_their_principals>-
Defines paths to keytab files that Samba maintains and the Kerberos principals in these files. With the shown value, Samba continues maintaining the
/etc/krb5.keytabsystem keytab and, additionally, a/etc/samba/cepces.keytabfile that thecepces-submitsubmission helper forcertmongeruses to authenticate to the CA. apply group policies = yes-
Configures the
winbindservice to execute thegpupdatecommand in intervals. The update interval is 90 minutes, plus a random offset between 0 and 30 minutes.
Create the
/etc/samba/cepces.keytabfile:# net ads keytab createEdit the
/etc/cepces/cepces.conffile, and make the following changes:In the
[global]section, set theservervariable to the fully-qualified domain name (FQDN) of the Windows server which runs the CA service:[global] server=win-server.ad.example.comIn the
[kerberos]section, set thekeytabvariable to/etc/samba/cepces.keytab:[kerberos] keytab=/etc/samba/cepces.keytab
Enable and start the
certmongerservice:# systemctl enable --now certmongerThe
certmongerservice requests the certificates from the CA and automatically renews them before they expire.Manually run
samba-gpupdateto ensure that the group policies have been loaded from AD:# samba-gpupdateThe
certmongerservice stores the keys and certificates in the following directories:-
Private keys:
/var/lib/samba/private/certs/ Issued certificates:
/var/lib/samba/certs/You can now start using the keys and certificates in services on the same host.
-
Private keys:
Optional: Display the certificates that
certmongermanages:# getcert list Number of certificates and requests being tracked: 1. Request ID 'AD-ROOT-CA.Machine': status: MONITORING stuck: no key pair storage: type=FILE,location='/var/lib/samba/private/certs/AD-ROOT-CA.Machine.key' certificate: type=FILE,location='/var/lib/samba/certs/AD-ROOT-CA.Machine.crt' CA: AD-ROOT-CA issuer: CN=AD-ROOT-CA,DC=ad,DC=example,DC=com subject: CN=rhel9.ad.example.com issued: 2025-03-25 14:22:07 CET expires: 2026-03-25 14:22:07 CET dns: rhel9.ad.example.com key usage: digitalSignature,keyEncipherment eku: id-kp-clientAuth,id-kp-serverAuth certificate template/profile: Machine profile: Machine pre-save command: post-save command: track: yes auto-renew: yesBy default, the Windows CA issues only a certificate by using the
Machinecertificate template. If you configured additional templates in the Windows CA that apply for this host,certmongerrequests certificates for these templates as well, and thegetcert listoutput includes also entries for them.