-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcentosKDC.sh
69 lines (50 loc) · 1.41 KB
/
centosKDC.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# https://gist.githubusercontent.com/abajwa-hw/f8b83e1c12abb1564531e00836b098fa/raw
export host=$(hostname -f)
export realm=${realm:-HORTONWORKS.COM}
export domain=${domain:-hortonworks.com}
export kdcpassword=${kdcpassword:-BadPass#1}
set -e
yum -y install krb5-server krb5-libs krb5-auth-dialog krb5-workstation
tee /var/lib/ambari-server/resources/scripts/krb5.conf > /dev/null << EOF
[logging]
default = FILE:/var/log/krb5libs.log
kdc = FILE:/var/log/krb5kdc.log
admin_server = FILE:/var/log/kadmind.log
[libdefaults]
default_realm = $realm
dns_lookup_realm = false
dns_lookup_kdc = false
ticket_lifetime = 24h
renew_lifetime = 7d
forwardable = true
[realms]
$realm = {
kdc = $host
admin_server = $host
}
[domain_realm]
.$domain = $realm
domain = $realm
EOF
/bin/cp -f /var/lib/ambari-server/resources/scripts/krb5.conf /etc
echo $kdcpassword > passwd
echo $kdcpassword >> passwd
kdb5_util create -s < passwd
service krb5kdc start
service kadmin start
chkconfig krb5kdc on
chkconfig kadmin on
kadmin.local -q "addprinc admin/admin" < passwd
rm -f passwd
tee /var/kerberos/krb5kdc/kadm5.acl > /dev/null << EOF
*/admin@$realm *
EOF
service krb5kdc restart
service kadmin restart
echo "Waiting to KDC to restart..."
sleep 10
service krb5kdc status
service kadmin status
#echo "Testing KDC..."
#kadmin -p admin/admin -w $kdcpassword -r $realm -q "get_principal admin/admin"
echo "KDC setup complete"