LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 01-31-2013, 06:48 PM   #1
gdizzle
Member
 
Registered: Jul 2012
Posts: 234

Rep: Reputation: Disabled
Wink Bash Script to generate entropy on a command


Hi all, I am trying to have a script that automates entropy to a given command.

Example command:

corosync-keygen : this command is awaiting input to generate entropy before it can complete.


Command that can generate entropy would be :

ls -R /

Now I am trying to figure out how to put them together in a script or run them SIDE-BY-SIDE, so that when the corosync-keygen command runs then the ls -R command can run in conjunction and generate the entropy needed so the command then completes.

Can anyone please help?

Thanks
 
Old 01-31-2013, 07:18 PM   #2
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.9, Centos 7.3
Posts: 17,374

Rep: Reputation: 2383Reputation: 2383Reputation: 2383Reputation: 2383Reputation: 2383Reputation: 2383Reputation: 2383Reputation: 2383Reputation: 2383Reputation: 2383Reputation: 2383
Use '&' to background the ls cmd?
http://rute.2038bug.com/index.html.gz

For lots of random, try
Code:
cat /dev/urandom

Last edited by chrism01; 01-31-2013 at 07:19 PM.
 
Old 01-31-2013, 10:40 PM   #3
gdizzle
Member
 
Registered: Jul 2012
Posts: 234

Original Poster
Rep: Reputation: Disabled
Just an FYI I am running this from a PUTTY SSH session.

Both: cat /dev/urandom & and "ls -R"/ & still print to STD OUT.

ls -R / & : this alone still prints to the screen and does not background.

cat /dev/urandom | corosync-keygen = no luck

cat /dev/urandom & corosync-keygen : this does not run it in the background, even when you add it as to a shell script.

Put this in a shell script tried it no luck


Most luck I have had is with this:

rngd -f -r /dev/urandom > /dev/console & corosync-keygen

watch -n 0.1 cat /proc/sys/kernel/random/entropy_avail : shows the most entropy.

I have a stab and let you know this goes, was hoping there was a way to generate entropy quicker. Might have to resort to dd.
 
Old 02-01-2013, 12:48 AM   #4
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.9, Centos 7.3
Posts: 17,374

Rep: Reputation: 2383Reputation: 2383Reputation: 2383Reputation: 2383Reputation: 2383Reputation: 2383Reputation: 2383Reputation: 2383Reputation: 2383Reputation: 2383Reputation: 2383
Yeah, sorry... even with &, stdout is still at cmd terminal; must have had a brain crash
Code:
cat /dev/urandom >/dev/null &
then run corosync-keygen in the foreground. Remember to kill the cat cmd when done (it'll give you the pid when it starts)
 
Old 02-01-2013, 07:17 AM   #5
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,702

Rep: Reputation: 1270Reputation: 1270Reputation: 1270Reputation: 1270Reputation: 1270Reputation: 1270Reputation: 1270Reputation: 1270Reputation: 1270
None of what you are doing generates good entropy - that can only be generated external to the system. Entropy is built up gradually over time - under the assumption that the time intervals of various system events is truly random.

Trying to rush the entropy accumulation is non-random, and results in poor entropy.
 
Old 02-02-2013, 04:32 PM   #6
gdizzle
Member
 
Registered: Jul 2012
Posts: 234

Original Poster
Rep: Reputation: Disabled
Thanks chrism01 for your help.

Best solution I found for the fastest scripted / generated entropy was:

Code:
while /bin/true; do dd if=/dev/urandom of=/tmp/100 bs=1024 count=100000; for i in {1..10}; do cp /tmp/100 /tmp/tmp_$i_$RANDOM; done; rm -f /tmp/tmp_* /tmp/100; done & /usr/sbin/corosync-keygen
Understood jpollard about good entropy, this was just needed as a scripted example. Thanks for your input.

Last edited by gdizzle; 02-02-2013 at 04:34 PM.
 
  


Reply


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
Why does this work from the bash command line and then fails in a bash script? Rupadhya Linux - Newbie 5 09-26-2012 12:05 AM
Command works when pasted at command line but not as bash script neild Programming 7 09-23-2012 07:30 AM
[SOLVED] Using a long Bash command including single quotes and pipes in a Bash script antcore Linux - General 9 07-22-2009 11:10 AM
Bash Script as command whited Programming 15 12-10-2007 06:14 AM
Simple Bash Script Help Command kemplej Linux - Software 1 03-11-2004 03:52 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:04 PM.

Main Menu
Advertisement
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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration