Automate the kinit process with a secure password

If in the event you want to automate the kinit process and automate this process at logon, the steps outlined below will work.  This has been tested on a CentOS 7 installation.

ktutil
ktutil:  addent -password -p username@DOMAIN.COM -k 1 -e rc4-hmac
Password for username@DOMAIN.COM: [enter your password]
ktutil:  addent -password -p username@DOMAIN.COM -k 1 -e aes256-cts
Password for username@DOMAIN.COM: [enter your password]
ktutil:  wkt username.keytab
ktutil:  quit
> mkdir /home/username/keytabs
> chmod 700 /home/username/keytabs
> mv username.keytab /home/username/keytabs
> chmod 600 /home/username/keytabs/username.keytab
> echo "kinit -kt /home/username/keytabs/username.keytab username@DOMAIN.COM" >> /home/username/.bash_profile

Another use case that seems to work, is to take that keytab since it is a portable file and copy it to another server and run the following command.

kinit -kt /home/username/keytabs/username.keytab username@DOMAIN.COM"

Source

  • https://community.hortonworks.com/questions/37074/automation-of-kinit-process-without-login-into-edg.html
  • https://docs.tibco.com/pub/spotfire_server/7.6.1/doc/html/tsas_admin_help/GUID-27726F6E-569C-4704-8433-5CCC0232EC79.html