How to make a Linux server (Centos7) to be a member of Active Directory Domain

1.  install linux package for this purpose :

[root@labnfs ~]# yum install sssd realmd oddjob oddjob-mkhomedir adcli samba-common samba-common-tools krb5-workstation openldap-clients policycoreutils-python -y



2.  point to DNS server where Active Directory (AD DNS) active :


[root@labnfs ~]# vi /etc/resolv.conf

[root@labnfs ~]# cat /etc/resolv.conf

# Generated by NetworkManager

nameserver 192.168.1.77  ==> AD DNS

nameserver 192.168.1.1   ==> default DNS from DHCP


note: if you have default DNS server using DHCP which is not part of AD DNS server and you modified name server in /etc/resolv.conf manually, network manager always overwrite /etc/resolv.conf with default DNS server. 


[root@labnfs dhcp]# cat /etc/resolv.conf   ==> always overwritten by network manager 

# Generated by NetworkManager

nameserver 192.168.1.1. 


to prevent that happened, you need to add preferred DNS into /etc/dhcp/dhclient.conf (if it doesn't exist,you can create dhclient.conf) :


[root@labnfs dhcp]# cat dhclient.conf

prepend domain-name-servers 192.168.1.77;



restart network and it's permanently added at the top:


[root@labnfs dhcp]# systemctl restart network

[root@labnfs dhcp]# cat /etc/resolv.conf

# Generated by NetworkManager

nameserver 192.168.1.77

nameserver 192.168.1.1


3.  join to windows domain :


[root@labnfs ~]# realm join  --user=Administrator batman.local

Password for Administrator: 



4.  check it on linux server whether it's been joined  windows domain or not :


[root@labnfs ~]# realm list

batman.local

  type: kerberos

  realm-name: BATMAN.LOCAL

  domain-name: batman.local

  configured: kerberos-member

  server-software: active-directory

  client-software: sssd

  required-package: oddjob

  required-package: oddjob-mkhomedir

  required-package: sssd

  required-package: adcli

  required-package: samba-common-tools

  login-formats: %U@batman.local

  login-policy: allow-realm-logins


OR

check it on Active Directory server :



5. Optional: if you don't want to use FQDN (Full Qualified Domain Name), you can do this :


[root@labnfs ~]# id Administrator@batman.local

uid=215400500(administrator@batman.local) gid=215400513(domain users@batman.local) groups=215400513(domain users@batman.local),215400520(group policy creator owners@batman.local),215400512(domain admins@batman.local),215400572(denied rodc password replication group@batman.local),215400519(enterprise admins@batman.local),215400518(schema admins@batman.local)


[root@labnfs ~]# cat /etc/sssd/sssd.conf


[sssd]

domains = batman.local

config_file_version = 2

services = nss, pam


[domain/batman.local]

ad_domain = batman.local

krb5_realm = BATMAN.LOCAL

realmd_tags = manages-system joined-with-samba 

cache_credentials = True

id_provider = ad

krb5_store_password_if_offline = True

default_shell = /bin/bash

ldap_id_mapping = True

use_fully_qualified_names = True  ==> changed to False

fallback_homedir = /home/%u@%d    ==> remove @%d

access_provider = ad


[root@labnfs ~]# vi /etc/sssd/sssd.conf

[root@labnfs ~]# cat /etc/sssd/sssd.conf


[sssd]

domains = batman.local

config_file_version = 2

services = nss, pam


[domain/batman.local]

ad_domain = batman.local

krb5_realm = BATMAN.LOCAL

realmd_tags = manages-system joined-with-samba 

cache_credentials = True

id_provider = ad

krb5_store_password_if_offline = True

default_shell = /bin/bash

ldap_id_mapping = True

use_fully_qualified_names = False

fallback_homedir = /home/%u

access_provider = ad


to make it active, restart sssd (System Security Services Daemon) :


[root@labnfs ~]# systemctl restart sssd

[root@labnfs ~]# id Administrator

uid=215400500(administrator) gid=215400513(domain users) groups=215400513(domain users),215400520(group policy creator owners),215400512(domain admins),215400572(denied rodc password replication group),215400519(enterprise admins),215400518(schema admins)

[root@labnfs ~]# 


6. Test login to your linux server using Active Directory user account (I made user account "bruce" already) :


aghiel@aghiel-mbproi9 ~ % ssh bruce@labnfs

bruce@labnfs's password: 

Last login: Fri Jun 19 06:54:04 2020 from 192.168.1.121

[bruce@labnfs ~]$ id bruce

uid=215401106(bruce) gid=215400513(domain users) groups=215400513(domain users)

[bruce@labnfs ~]$ 


Active Directory user account :




7. It's done.

Comments

Popular posts from this blog

OSS RC : learning by doing (new beginning)

Link sudoers in linux (centos7) with Active Directory group

RSYNC via SSH on solaris 10