Advertisement
Guest User

Untitled

a guest
Jul 18th, 2017
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.39 KB | None | 0 0
  1. # Join Linux to Active Directory (RHEL/CentOS)
  2.  
  3. Below is what an admin would do manually. You will need to adjust the variables to work for you, obviously. These steps are similar in debian based Linux distributions, but with a twist. I didn't document that here, as I didn't see the need. They are relatively minor changes.
  4.  
  5.  
  6. 1. Export some variables that we'll need.
  7. ```
  8. ### Set your domain
  9. export adauth_domain=YOURDOMAIN.LAB
  10.  
  11. ### Set the OU of this host will be added to
  12. export adauth_server_ou="DC=YOURDOMAIN,DC=LAB"
  13.  
  14. ### Set a user who has access to add objects to the domain
  15. export adauth_user="lxadjoin"
  16.  
  17. ### Set the password for the user above.
  18. export adauth_pass="cya+SdhfWZBUze+q"
  19.  
  20. ### Validate that our variables exported correctly
  21. set | grep ^adauth.*$
  22. ```
  23.  
  24. 2. Install the required packages:
  25. ```
  26. yum install -y epel-release \
  27. libselinux-python \
  28. adcli \
  29. oddjob \
  30. oddjob-mkhomedir \
  31. sssd-client \
  32. sssd-ad \
  33. sssd-krb5 \
  34. sssd-krb5-common \
  35. krb5-workstation
  36. ```
  37.  
  38.  
  39. 3. Join the server to the domain:
  40.  
  41. ```
  42. echo -n ${adauth_pass} | \
  43. /usr/sbin/adcli join --stdin-password -O ${adauth_server_ou} \
  44. -U ${adauth_user} -D ${adauth_domain} -H $(hostname -f) \
  45. --user-principal=host/$(hostname -f)@${adauth_domain^^}
  46.  
  47. ### Backup existing krb5.conf
  48. cp /etc/krb5.conf{,.$(date +%s)}
  49.  
  50. ### Create new krb5.conf
  51. cat <<EOF>/etc/krb5.conf
  52.  
  53. [libdefaults]
  54. default_realm = ${adauth_domain^^}
  55. default_keytab_name = /etc/krb5.keytab
  56. dns_lookup_kdc = true
  57.  
  58. [domain_realm]
  59. .${adauth_domain,,} = ${adauth_domain^^}
  60. ${adauth_domain,,} = ${adauth_domain^^}
  61.  
  62. [logging]
  63. default = FILE:/var/log/krb5libs.log
  64. kdc = FILE:/var/log/krb5kdc.log
  65. admin_server = FILE:/var/log/kadmind.log
  66.  
  67. EOF
  68.  
  69. ### set permissions on /etc/krb5.conf
  70. chmod 0644 /etc/krb5.conf
  71. ```
  72.  
  73. 4. Configure SSSD
  74. ```
  75. cat <<EOF>>/etc/sssd/sssd.conf
  76. [nss]
  77. filter_groups = root
  78. filter_users = root
  79. reconnection_retries = 3
  80.  
  81. [pam]
  82. reconnection_retries = 3
  83.  
  84. [ssh]
  85.  
  86. [sssd]
  87. config_file_version = 2
  88. reconnection_retries = 3
  89. sbus_timeout = 30
  90. services = nss, pam, ssh
  91. dns_discovery_domain = ${adauth_domain,,}
  92. domains = ${adauth_domain^^}
  93. debug_level = 0x0150
  94.  
  95. [domain/${adauth_domain^^}]
  96. debug_level = 0x0150
  97. enumerate = false
  98. cache_credentials = false
  99.  
  100. # set providers
  101. id_provider = ad
  102. access_provider = ad
  103. auth_provider = ad
  104.  
  105. # need to set the realm for krb auth
  106. krb5_realm = ${adauth_domain^^}
  107.  
  108. # ad info
  109. ad_domain = ${adauth_domain,,}
  110. ad_hostname = $(hostname -f)
  111.  
  112. # set dns update refresh interval in seconds
  113. dyndns_refresh_interval = 14400
  114.  
  115. # enabled by default in 1.13.4, which causes us issues
  116. ad_gpo_access_control = disabled
  117.  
  118. # changing how the id mapping works for uid/gid since those aren't in ad
  119. ldap_id_mapping = true
  120. ldap_schema = ad
  121. override_homedir = /home/%u
  122. default_shell = /bin/bash
  123. ldap_user_shell = loginShell
  124.  
  125. # pull in public key from ad
  126. ldap_user_ssh_public_key = altSecurityIdentities
  127.  
  128. EOF
  129.  
  130. ```
  131.  
  132. 5. Configure PAM modules
  133. ```
  134. authconfig --enablesssd --enablesssdauth \
  135. --disableldap --disableldapauth --disablekrb5 --enablemkhomedir --update
  136. ```
  137.  
  138. 6. Enable the SSSD service & Make sure it has started
  139. ```
  140. systemctl enable sssd
  141. systemctl restart sssd
  142. ```
  143.  
  144. 7. Enable the oddjobd service & make sure it is started
  145. ```
  146. systemctl enable oddjobd
  147. systemctl restart oddjobd
  148. ```
  149.  
  150. ### Post Setup
  151. At this point, the host should be joined. You can validate this by attempting to login. Another useful tool is getent:
  152. ```getent passwd ad_username```
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement