#!/bin/sh

kdb5_util create -s -P $PASSWORD
kadmin.local -q "addprinc $USER/admin" <<EOF
$PASSWORD
$PASSWORD
EOF

kadmin.local <<EOF
addprinc -randkey host/$FQDN
ktadd -k /etc/krb5.keytab host/$FQDN
EOF

# Enable and start the Kerberos servers
chkconfig kadmin on
chkconfig krb5kdc on
service kadmin start
service krb5kdc start

# Restart sshd so that it uses the new keytab
service sshd restart

