I want to make a script that will generate the a keytab using ktutil. When running the script I want to use [user]$ script.sh PASSWORD
#script.sh
echo "addent -password -p PRINCIPAL -k 1 -e aes256-cts-hmac-sha1-96" | ktutil
Ktutil than needs a password, here I want to use the PASSWORD argument from above. How would I pass the password arguement?
With GNU bash:
Output:
To create the multiple orgs keytabs and default hbase,pipe,hdfs keytab at the same time you can run the below script, which i have just created:
A version in Python
https://github.com/Tagar/stuff/blob/master/keytab.py
piping password to ktutil in shell is not secure as password will be visible in list of processes.
Since this Python scripts just interacts with ktutil using pexpect library, it's possible to implement the same as a pure shell script using expect.
Hope this helps.