#!/bin/bash

#Add a principal to the KDC for the master node, using the master node's returned host name
sudo kadmin.local -q "ktadd -k /etc/krb5.keytab host/`hostname -f`"
#Assign plain language variables for clarity
name=tyler
password=derpderp
sudo kadmin.local -q "addprinc -pw $password +needchange $name"
hdfs dfs -mkdir /user/$name
hdfs dfs -chown $name:$name /user/$name

# Enable GSSAPI authentication for SSH and restart SSH service
sudo sed -i 's/^.*GSSAPIAuthentication.*$/GSSAPIAuthentication yes/' /etc/ssh/sshd_config
sudo sed -i 's/^.*GSSAPICleanupCredentials.*$/GSSAPICleanupCredentials yes/' /etc/ssh/sshd_config
sudo /etc/init.d/sshd restart
