Generate md5 password in a script
In my script i want to read a users input for what they want their grub password to be and store in $Password.
Then i need to generate a md5 hash from that password.
Usually you use grub-md5-crypt to generate the hash but that has prompts and i don't know how to handle that in a script. Is their some sort of function i can call and pass in my $Password variable as input?
I ended up getting both md5pass and grub-md5-crypt to work although i prefer the latter even though i don't understand the difference between the two yet.
My parse produces the expected result but it doesn't work in my kickstart for some weird reason.
I get error: A single argument is expected for the rootpw command
For the benefit of the community here is how i parsed it out:
rootHash="$(echo -e "$rootPass\n$rootPass" | grub-md5-crypt 2>/dev/null | tail --lines=1)"
echo -e "\nrootpw --iscrypted" $rootHash >> /tmp/Variables.cfg
to make sure i only get the hash i use 2>/dev/null to send the prompts "Type password" and "Retype password" into null oblivion
I use tail --lines=1 to grab the last thing in the line which happens to be the hash.
My initial question is solved though so i will mark this solved.
|All times are GMT -5. The time now is 11:57 PM.|