In questo tutorial, discuteremo come integrare i server Linux (Centos/RHEL) con Windows Active Directory per scopi di autenticazione. Nel mio caso, ho server Centos/RHEL 6. Segui i passaggi seguenti per integrare questi server con AD utilizzando samba, winbind e Kerberos.
Passaggio 1 :Installa i pacchetti samba-winbind e kerberos.
# yum install samba-winbind samba-winbind-clients samba krb5-libs krb5-workstation pam_krb5
Passaggio 2 :Sincronizzazione dell'ora.
AD è molto esigente riguardo alla corrispondenza dell'ora durante l'autenticazione. Quindi l'ora del server Linux e del server AD dovrebbe essere sincronizzata con il server ntp. Utilizzare il comando seguente per sincronizzare l'ora del server Linux con il server ntp.
# ntpdate [ntp-server-ip-address/dns-name]
Per rendere permanente la configurazione di cui sopra, modifica il file "/etc/ntp.conf" e sostituisci semplicemente quello che c'è con uno o più server NTP sul tuo dominio, come:
# vi /etc/ntp.conf server [ntp-server-ip-address/dns-name]
Avvia il servizio:
# /etc/init.d/ntpd start # chkconfig ntpd on
Passaggio 3 :Modifica il file /etc/hosts.
# vi /etc/hosts [ip-address] adserver.yourdomain adserver
Passaggio 4 :Modifica /etc/krb5.conf.
# vi /etc/krb5.conf
[domain_realm]
yourdomain = YOURDOMAIN
[libdefaults]
ticket_lifetime = 24000
default_realm = YOURDOMAIN
dns_lookup_realm = true
dns_lookup_kdc = false
cache_type = 1
forwardable = true
proxiable = true
default_tgs_enctypes = des3-hmac-sha1 des-cbc-crc
permitted_enctypes = des3-hmac-sha1 des-cbc-crc
allow_weak_crypto = no
[realms]
YOURDOMAIN = {
kdc = [ip address of AD server:Port]
admin_server = [ip address of AD server:Port]
default_domain = yourdomain
} [appdefaults]
pam = {
debug = true
ticket_lifetime = 36000
renew_lifetime = 36000
forwardable = true
krb4_convert = false
}
[logging]
default = FILE:/var/krb5/kdc.log
kdc = FILE:/var/krb5/kdc.log
admin_server = FILE:/var/log/kadmind.log Passaggio 5 :ora verifica l'autenticazione Kerberos.
# kinit [user-name]
Se richiede la password, inserisci la password dell'annuncio utente, se tutto è a posto, riceveremo la richiesta, altrimenti ricontrolla il file krb5.conf.
Passaggio 6 :Ora configura Samba e Winbind.
Modifica /etc/samba/smb.conf .
# vi /etc/samba/smb.conf
[global]
workgroup = [Workgroup-Name]
netbios name = site2 ## replace the site2 with hostname
realm =
security = ADS
template shell = /bin/bash
idmap backend = tdb
idmap uid = 1-100000000
idmap gid = 1-100000000
winbind use default domain = Yes
winbind nested groups = Yes
winbind enum users = Yes
winbind enum groups = Yes
template shell = /bin/bash
template homedir = /home/%D/%U
winbind separator = /
winbind nss info = sfu
winbind offline logon = true
hosts allow = 127.0.0.1 0.0.0.0/0
obey pam restrictions = yes
socket options = TCP_NODELAY
max log size = 150
passdb backend = tdbsam
printing = cups
load printers = yes
cups options = raw
printcap name = cups
disable spoolss = Yes
show add printer wizard = No
interfaces = eth0 lo
bind interfaces only = yes
winbind refresh tickets = true
log file = /var/log/samba/log.%m
max log size = 50
log level = 3
encrypt passwords = yes
#map untrusted to domain = yes
#auth methods = winbind guest sam
map untrusted to domain = Yes
[printers]
comment = All Printers
path = /var/spool/samba
browseable = yes
public = yes
guest ok = yes
writable = no
printable = yes Passaggio 7 :Configura /etc/nsswitch.conf file per gestire l'autenticazione.
# vi /etc/nsswitch.conf passwd: compat winbind shadow: winbind group: compat winbind
Passaggio 8 :Ora riavvia i servizi winbind e Samba.
# /etc/init.d/smb restart # /etc/init.d/winbind restart
Ora unisciti a un dominio:
# net ads join -U [User Name]
Se il comando precedente riporta "Join is OK", quindi prova winbind:
Comando per elencare tutti gli utenti AD:
# wbinfo -u
Passaggio 9 :Ora esegui il test e prova ad accedere al server Linux tramite le credenziali dell'utente AD.
# ssh [username]@[ipaddress or hostname of linux server]