how to Authenticate and Integrate Linux with Windows Active Directory


Scope: authenticate windows AD users to linux machine by using thier windows credential

Step:1 Install the samba-winbind and kerberos packages
# yum install samba-winbind samba-winbind-clients samba krb5-libs krb5-workstation pam_krb5

Step:2 Time synchronization
Time of your linux and windows AD should be matched so make it sure first before moving ahead.
Windows AD itself ( primary or parent domain controller) works as a ntp server hence yopu can use windows ad to sync your linux time by using bellow method
# ntpdate <ntp-server-ip-address/dns-name>
To make above configuration permanent edit the file “/etc/ntp.conf” and just replace what's there with one or more NTP servers on your domain, like
server <ntp-server-ip-address/dns-name>

Start the Service :
# /etc/init.d/ntpd start ; chkconfig ntpd on
Step:3 DNS settings
make sure your linux machine has proper fqdn hostname. Make an entry in your dns which you are using for windows ad and linux machine, corresponding entries (A record) should be updated. Though make change in local hosts file for name resolution.
# vi /etc/hosts
<ip-address> ad.mydomain.com ad
<ip-address> linux.mydomain.com linux

Step:4 Edit /etc/krb5.conf
[logging]
default = FILE:/var/log/krb5libs.log
kdc = FILE:/var/log/krb5kdc.log
admin_server = FILE:/var/log/kadmind.log
[libdefaults]
default_realm = MYDOMAIN.COM
dns_lookup_realm = true
dns_lookup_kdc = false
ticket_lifetime = 24h
renew_lifetime = 7d
forwardable = true
[realms]
MYDOMAIN.COM = {
kdc = ad.mydomain.com
admin_server = ad.mydomain.com
}
[domain_realm]
.mydomain.com = MYDOMAIN.COM
mydomain.com = MYDOMAIN.COM

Step:5 Now Test the Kerberos Authentication
# kinit <user-name> ( windows AD user name)
If it prompts for the password , enter password , if every thing is ok , then we will get the prompt otherwise re-check krb5.conf file.
Step:6 Now Configure Samba and Winbind

Edit /etc/samba/smb.conf
find [global ] and make or modify entries as bellow
workgroup = MYDOMAIN
password server = ad.mydomain.com
realm = MYDOMAIN.COM
security = ads
idmap uid = 10000-500000
idmap gid = 10000-500000
template shell = /bin/bash
winbind use default domain = true
winbind offline logon = false
winbind nested groups = yes


Step:7 Configure /etc/nsswitch.conf file to handle authentication.
passwd: file winbind
shadow: file winbind
group: file winbind

Step:8 Now restart winbind & Samba services
# /etc/init.d/smb restart
# /etc/init.d/winbind restart

Now join a domain
# net ads join -U <User Name> (note : user name must have priviledges to join a system on domain)
Now enable winbind authentication and automatic home directory  creation for linux machine
# authconfig --enablewinbind --enablewinbindauth --enablemkhomedir --update

If above command reports "Join is OK", then test winbind:
Command to lists all the AD users
# wbinfo -u
Command to lists all the AD groups
# wbinfo -g

Comments

Popular posts from this blog

Running web ssh client on port 443 /80 with nginx as reverse proxy

Running cockpit behind nginx reverse proxy with nginx ssl and cockpit non ssl

Setup VOD streaming server with nginx using RTMP on Ubuntu 18.04