Skip to content

Instantly share code, notes, and snippets.

@rafaelfoster
Last active August 29, 2015 14:09
Show Gist options
  • Save rafaelfoster/8e354ddbef98dac3693c to your computer and use it in GitHub Desktop.
Save rafaelfoster/8e354ddbef98dac3693c to your computer and use it in GitHub Desktop.
Configure and RHEL based server to login through Active Directory Group using winbind
$DOMAIN=example.com.br
$REALM=EXAMPLE
$AD_ADMIN_GROUP=ad_admingroup
# Install necessary packages
yum install samba-common pam_krb5 sudo authconfig samba-winbind-clients
# it should appear the system hostname followed by ".$DOMAIN"
hostname -f
# Create home base dir to domain users
mkdir /home/$DOMAIN
# Join the machine to domain
net join -w $DOMAIN -S $DOMAIN -U username
# Create samba configurations to specific domain
authconfig \
--disablecache \
--enablewinbind \
--enablewinbindauth \
--smbsecurity=ads \
--smbworkgroup=$REALM \
--smbrealm=$DOMAIN \
--enablewinbindusedefaultdomain \
--winbindtemplatehomedir=/home/$REALM/%U \
--winbindtemplateshell=/bin/bash \
--enablekrb5 \
--krb5realm=$DOMAIN \
--enablekrb5kdcdns \
--enablekrb5realmdns \
--enablelocauthorize \
--enablemkhomedir \
--enablepamaccess \
--updateall
echo "%$AD_ADMIN_GROUP ALL=(ALL) ALL" >> /etc/sudoers
/etc/pam.d/password-auth
#%PAM-1.0
# This file is auto-generated.
# User changes will be destroyed the next time authconfig is run.
auth required pam_env.so
auth sufficient pam_unix.so nullok try_first_pass
auth requisite pam_succeed_if.so user ingroup $REALM\$AD_ADMIN_GROUP debug
[...]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment