Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

通过这部分代码可以看出,krbDefaultEncSaltTypes 属性,影响生成 keytab 的加密方式。那么我尝试修改 ldap 中的这两个值。

修改部分 attrbutes,可以影响 kdc 的加密算法。

Code Block
ldapsearch -x -D "cn=directory manager" -w hadoop123 "objectClass=krbrealmcontainer"
ldapmodify -x -D "cn=directory manager" -w hadoop123 -f modify.ldif

...

Code Block
#!/bin/bash

set -x
KEYTAB=$1
printf "addent -password -p admin -k 1 -e aes256-cts\nhadoop123\naddent -password -p admin -k 1 -e aes128-cts\nhadoop123\nwrite_kt $KEYTAB\nquit" | ktutil

比较这两个 keytab 是否相同即可。

Code Block
#!/bin/bash

set -x
KEYTAB=$1
printf "read_kt $KEYTAB\nlist -k -t -e\nquit" | ktutil

第二个问题,注册服务的 principal。这个是 CM 调用 /usr/share/cmf/bin/gen_credentials.sh,这个脚本可以配置,因为是使用 freeipa 管理,所以我们需要自己定义一个获取凭证的脚本。如下:

Code Block
#!/usr/bin/env bash

set -e
set -x

# Explicitly add RHEL5/6, SLES11/12 locations to path
export PATH=/usr/kerberos/bin:/usr/kerberos/sbin:/usr/lib/mit/sbin:/usr/sbin:/usr/lib/mit/bin:/usr/bin:$PATH

KEYTAB_OUT=$1
PRINC=$2
MAX_RENEW_LIFE=$3

IPASERVER=`ipa env server|sed 's/  server: //g'`

kinit -kt /opt/cloudera/freeipa/admin.keytab admin

if ipa service-find $PRINC; then
    echo Service principle $PRINC found
else
    echo Service principle $PRINC not created, creating
    ipa service-add $PRINC --pac-type=NONE
fi

if ipa service-show $PRINC | grep 'Keytab' | grep 'False'; then
    echo Creating keytab for $PRINC for $KEYTAB_OUT
    ipa-getkeytab -s $IPASERVER -p $PRINC -k $KEYTAB_OUT
else
    echo Retrieving keytab for $PRINC for $KEYTAB_OUT
    ipa-getkeytab -r -s $IPASERVER -p $PRINC -k $KEYTAB_OUT -D "cn=directory manager" -w hadoop123
fi

chmod 600 $KEYTAB_OUT

kdestroy


krb5kdc - Kerberos V5 KDC

...