Created
June 11, 2020 04:58
-
-
Save wilkersoncs/037141d9241524a59e62ad88e7fb1605 to your computer and use it in GitHub Desktop.
Script to join CentOS machine to AD domain
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Script to join CentOS machine to AD domain | |
# tested on CentOS 7.8 and Windows 2016 | |
# Adapted from https://www.linuxtechi.com/integrate-rhel7-centos7-windows-active-directory/ | |
# $1 is domain, $2 is DNS IP, $3 is domain admin name | |
cd /etc | |
# resolv.conf is replaced by network manager if you use DHCP. Make sure your DHCP server | |
# has the correct DNS server | |
cp resolv.conf resolv.conf.orig | |
echo "search $1" > resolv.conf | |
echo "nameserver $2" >> resolv.conf | |
yum install -y sssd realmd oddjob oddjob-mkhomedir adcli samba-common samba-common-tools krb5-workstation openldap-clients policycoreutils-python | |
realm join --user=$3 $1 | |
realm list | |
cd /etc/sssd | |
cp sssd.conf sssd.conf.orig | |
sed -i 's/use_fully_qualified_names = .*$/use_fully_qualified_names = False/' sssd.conf | |
sed -i 's`fallback_homedir = .*$`fallback_homedir = /home/%u`' sssd.conf | |
systemctl restart sssd | |
# Either of these assume a domain group sudoers, the second option skips prompting for a password | |
#echo "%sudoers ALL=(ALL) ALL" >> /etc/sudoers | |
#echo "%sudoers ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment