Installation and configuration of Openldap|Kerberos server with openldap SASL Passthrough
This is the article for setting up Centos7 with openldap authentication and kerberos backend to enable SSH single sign on(SSO). And SASL service will be installed and configured to allow sasl pass-through on openldap.
What is Openldap SASL pass-through
To explain in simple words, Openldap SASL pass-through delegating authentication operation from openldap to kerberos(In our case). So that we can maintain just one password for both ldap and kerberos user. otherwise we have to use one password for ldap authentication another one for kerberos authentication and ticket generation.
All we need to do is, while creating user in ldap using ldif file we have to specify below value instead of user passoword.
userPassword: {SASL}testuser1@TANU.COM
SASL Service installation:
My shell script will take care of installation and configuration of sasl service as part of ldap/kerberos server setup by invoking below function.
| install_sasl_service(){ |
| |
| yum -y install cyrus-sasl |
| |
| banner_msg "INFO: Creating /etc/sasl2/slapd.conf file for LDAP Sasl authencation" |
| banner_msg "INFO: dont fotget to copy /etc/ssl/certs/${kerberos_server_hostname}/MyRootCA.pem file from kerber server to all the client in same folder path otherwise LDAP bind will not work" |
| |
| cat > /etc/sasl2/slapd.conf <<- "EOF" |
| mech_list: external gssapi plain |
| pwcheck_method: saslauthd |
| EOF |
| |
| echo "SOCKETDIR=/var/run/saslauthd" >>/etc/sysconfig/saslauthd |
| echo "MECH=kerberos5" >>/etc/sysconfig/saslauthd |
| echo "KRB5_KTNAME=/etc/krb5.keytab" >>/etc/sysconfig/saslauthd |
| systemctl restart saslauthd.service |
| |
| } |
|
Openldap|kerberos server installation:
I have used two google cloud VM instances for setting up Openldap and kerberos server and ldap client.
Setting up kerberos and openldap server
Kerberos-server detail --> Centos7 --> hostname is idm.tanu.com
login into the kerberos-server host.
Install git client -
yum install -y install git-core
Download the Installation scripts -
git clone https://github.com/skumarx87/openldap_MIT-Kerberos_installation
Edit the shell script and update the main function with your details:
In my tutorial i have used kerberos domain with TANU.COM everywhere.
and then run the script with following option for server setup:
cd openldap_MIT-Kerberos_installation
./kerberos_ldap_installation.sh server_setup
This shell script with server installation input will invoke following functions. you find the list of commands being executed by each function.
create_root_ca_pair
creating_ldap_ssl_pair_pem
openldap_installation
install_sasl_service
enable_ldap_tls
install_kerberos_server
enable_kerberos_ldap_backend
creating_kerberos_db
Creating test users and groups
I primarily developed this script for to setup hadoop cluster for that set of users and groups need to be created. we can create same users and groups to test our installation.
Below file has users and respective groups information which will be created in Ldap and kerberos with default password mentioned in the script hadoop_users_password="support123"
[root@idm openldap_MIT-Kerberos_installation]# cat hadoop_users_map.txt
##############################
#username:group1,group2,etc #
##############################
cloudera-scm:cloudera-scm
accumulo:accumulo
flume:flume
hbase:hbase
hdfs:hdfs,hadoop
hive:hive
httpfs:httpfs
hue:hue
apache:apache
impala:impala,hive
kafka:kafka
kms:kms
keytrustee:keytrustee
kudu:kudu
llama:llama
mapred:mapred,hadoop
oozie:oozie
solr:solr
spark:spark
sentry:sentry
sqoop:sqoop
sqoop2:sqoop,sqoop2
yarn:yarn,hadoop
you will see below logs while adding.
adding new entry "uid=sqoop2,ou=People,dc=tanu,dc=com"
adding new entry "uid=yarn,ou=People,dc=tanu,dc=com"
adding new entry "uid=zookeeper,ou=People,dc=tanu,dc=com"
Principal "sqoop2@TANU.COM" created.
Creating kdc user principle yarn
Authenticating as principal root/admin@TANU.COM with password.
WARNING: no policy specified for yarn@TANU.COM; defaulting to no policy
Principal "yarn@TANU.COM" created.
Creating kdc user principle zookeeper
Authenticating as principal root/admin@TANU.COM with password.
WARNING: no policy specified for zookeeper@TANU.COM; defaulting to no policy
Principal "zookeeper@TANU.COM" created.
Setting up kerberos and openldap client:
run this command on all the client hosts(we could run on kerberos server host as well)
./kerberos_ldap_installation.sh client_setup
---------------------------------------------------
INFO: creating krb5.conf file
---------------------------------------------------
Cannot set persistent booleans without managed policy.
---------------------------------------------------
INFO: Creating host keytab file
---------------------------------------------------
Authenticating as principal root/admin@TANU.COM with password.
WARNING: no policy specified for user5@TANU.COM; defaulting to no policy
Principal "user5@TANU.COM" created.
Authenticating as principal root/admin@TANU.COM with password.
WARNING: no policy specified for host/idm.tanu.com@TANU.COM; defaulting to no policy
Principal "host/idm.tanu.com@TANU.COM" created.
Authenticating as principal root/admin@TANU.COM with password.
Entry for principal host/idm.tanu.com with kvno 2, encryption type aes256-cts-hmac-sha1-96 added to keytab WRFILE:/etc/krb5.keytab.
Entry for principal host/idm.tanu.com with kvno 2, encryption type aes---------------------------------------------------
INFO: creating krb5.conf file
---------------------------------------------------
Cannot set persistent booleans without managed policy.
---------------------------------------------------
INFO: Creating host keytab file
---------------------------------------------------
Authenticating as principal root/admin@TANU.COM with password.
WARNING: no policy specified for user5@TANU.COM; defaulting to no policy
Principal "user5@TANU.COM" created.
Authenticating as principal root/admin@TANU.COM with password.
WARNING: no policy specified for host/idm.tanu.com@TANU.COM; defaulting to no policy
Principal "host/idm.tanu.com@TANU.COM" created.
Authenticating as principal root/admin@TANU.COM with password.
Entry for principal host/idm.tanu.com with kvno 2, encryption type aes256-cts-hmac-sha1-96 added to keytab WRFILE:/etc/krb5.keytab.
Entry for principal host/idm.tanu.com with kvno 2, encryption type aes128-cts-hmac-sha1-96 added to keytab WRFILE:/etc/krb5.keytab.128-cts-hmac-sha1-96 added to keytab WRFILE:/etc/krb5.keytab.
Verify the server installation
[root@idm openldap_MIT-Kerberos_installation]# kadmin.local
Authenticating as principal root/admin@TANU.COM with password.
kadmin.local: listprincs
K/M@TANU.COM
krbtgt/TANU.COM@TANU.COM
kadmin/idm.tanu.com@TANU.COM
kadmin/admin@TANU.COM
kadmin/changepw@TANU.COM
kiprop/idm.tanu.com@TANU.COM
root/admin@TANU.COM
verify client installation:
login into client host with one of the hadoop user hdfs and password in default support123. you should able to login
[skumarx87@idm ~]$ su - hdfs
Password:
Last login: Sun Sep 1 02:32:20 UTC 2019 on pts/0
[hdfs@idm ~]$ id
uid=3005(hdfs) gid=2005(hdfs) groups=2005(hdfs),2028(hadoop) context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023
[hdfs@idm ~]$
There shouldn't be any kerberos ticket by default. we confirm by running klist. now try to create kerberos ticket by kinit command with same password.
[hdfs@idm ~]$ klist
klist: No credentials cache found (filename: /tmp/krb5cc_3005)
[hdfs@idm ~]$ kinit hdfs
Password for hdfs@TANU.COM:
[hdfs@idm ~]$ klist
Ticket cache: FILE:/tmp/krb5cc_3005
Default principal: hdfs@TANU.COM
Valid starting Expires Service principal
09/01/2019 02:34:18 09/02/2019 02:34:18 krbtgt/TANU.COM@TANU.COM
[hdfs@idm ~]$
issues and resolutions
Trying to run kadmin from the client machine since kadmin.local command will work only from the kerberos server.
Error:
kadmin: Client 'root/admin@TANU.COM' not found in Kerberos database while initializing kadmin interface
Solution :
I forgot to create root principle in kerberos server. after i ran below command, i was able to run kadmin command from any client hosts
kadmin.local -q "addprinc -pw ${KDC_ADMIN_PASSWD} root/admin@${KRB_DOMAIN_NAME}"
Error:
saslauthd[3123]: auth_krb5: k5support_verify_tgt
Solution :
kadmin.local -q "addprinc -randkey host/${CLIENT_FQDN_HOST}@TANU.COM"
kadmin.local -q "ktadd -k /etc/krb5.keytab host/${CLIENT_FQDN_HOST}
cat /etc/sysconfig/saslauthd
KRB5_KTNAME=/etc/krb5.keytab