-
Notifications
You must be signed in to change notification settings - Fork 0
/
bash_kerberos_health_check.sh
38 lines (32 loc) · 1.18 KB
/
bash_kerberos_health_check.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
#!/bin/bash
#filename: kerberos_health_checker.sh.
#description: make sure kerbose is still functional on a Linux host.
user="mydomainuser"
DOMAIN="MYDOMAIN"
join_domain() {
if [[ -e "/usr/sbin/realm" ]]; then #use realm
realm join -U $user $DOMAIN
elif [[ -e "/usr/sbin/adcli" ]]; then #use adcli
adcli join --domain=$DOMAIN --login-user=$user
#adcli join --domain-controller=dce.example.net --domain-ou='ou=Computers,ou=Linux,dc=example,dc=net' --login-user='$user'
else
echo "unknown paramater"
fi
}
#check for a keytab file
if [[ -e "/etc/krb5.keytab" ]]; then
echo "keytab file exists: It looks like we have a domain registration."
else
echo "the /etc/krb5.keytab file is missing. It looks like Kerbose is not setup right. Re-join the domain with 'adcli' or 'realmd'"
#rejoin the domain
join_domain
fi
#check for an active ticket
klist_check=$(klist -l | grep -i persistent| wc -l)
if [[ klist_check -eq 1 && $? == 0 ]] ; then
echo "We seem to have an active kerbose ticket. Logins should work."
else
echo "We are missing a ticket. Logins could start to fail soon."
echo "kinit $user@DOMAIN may fix this. "
kinit -V $user@$DOMAIN
fi