LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 07-31-2012, 11:33 AM   #1
Rogue45
Member
 
Registered: Jun 2012
Posts: 47

Rep: Reputation: Disabled
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?
 
Old 07-31-2012, 12:52 PM   #2
alinas
Member
 
Registered: Apr 2002
Location: UK, Sywell, EGBK
Distribution: RHEL, SuSE, CentOS, Debian, Ubuntu
Posts: 60

Rep: Reputation: 20
Try md5pass.
 
1 members found this post helpful.
Old 07-31-2012, 03:33 PM   #3
Rogue45
Member
 
Registered: Jun 2012
Posts: 47

Original Poster
Rep: Reputation: Disabled
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.
 
  


Reply

Tags
grub, kickstart, password


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to generate MD5 password rajes4india Linux - Security 2 10-06-2011 10:58 AM
MD5 password exposed Fredde87 Linux - Security 5 06-08-2010 05:22 PM
MD5 Encrypted Password gjagadish Linux - Security 1 09-28-2007 03:39 AM
MD5 and password encryption SlowCoder Linux - Security 2 07-22-2007 08:08 AM
How to generate a list of MD5 checksums? General Linux - Software 2 06-10-2006 09:59 PM


All times are GMT -5. The time now is 09:13 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration