stevepedwards.com/DebianAdmin linux mint IT admin tips info

Byobu and Entropy – A Truly Random Discovery Post

The great thing about the internet – if you don't spend all your time waffling pointless shite on Facebook, Twitter etc. of course – is that it is a continuous education at your fingertips.

I stumbled across byobu on Will Shotts http://lcorg.blogspot.co.uk/search/label/Commands

and was curious as his screenshots jpgs are not visible.

This led to installing the package to have a look:

sudo apt-get install byobu

Once installed and run, you get a normal terminal with some extra sysinfo at the bottom, which you can amend by pressing F9, toggle status info, and add or remove options using Spacebar as usual:

I like to have terms that show info about the system to save you running an extra app like top in that terminal, so you can continue to use it for cmd line work and still see the general state of a machine – great if you run remote machines of course – sysstate at a glance.

It's just made the perl script on the Notepad page obsolete too...

Whilst browsing the byobu manual pages at https://help.ubuntu.com/community/Byobu

and reading:

Status and Caption Lines

Byobu displays two lines at the bottom of your screen. The upper one is the Caption line, and the lower one is the Hard Status.

bottom.png

The Caption line shows your open windows, and highlights the one upon which you are focused, and optionally displays your user name, host name, IP address, and a hint that there is a Menu available if you press F9.

The Hard Status line consists of color coded output and symbols with configurable and dynamically updated facts, statistics, and information about the local system. See the Status Notifications section below for more information.

I came across the term entropy on: http://manpages.ubuntu.com/manpages/xenial/en/man1/byobu.1.html

which I do not fully understand – known only to me as a term in physics relating entropy to chaos – through unclear “definitions” that poorly explain the topic under discussion – which relates to heat energy in this case - such as:

Entropy is the universal tendency toward disorder, disorganization, disintegration and chaos. Newton's Second Law of Thermodynamics, also known as the Law of Increased Entropy, states, “the total entropy of any isolated system will increase over time, approaching a maximum value.”

Or:

In thermodynamics, entropy is commonly associated with the amount of order, disorder, or chaos in a thermodynamic system…In the context of entropy, "perfect internal disorder" is synonymous with "equilibrium", but since that definition is so far different from the usual definition implied in normal speech, the use of the term in science has caused a great deal of confusion and misunderstanding.

Really…?

Anyway, who cares about Thermodynamics definitions? This is an IT site.

Basically, my definition, after some thought is:

minimum entropy is no heat, so is no kinetic motion, so no random movement of atoms. It thus measures maximum order as the system state is fixed and perfectly definable – no chaos!

Sounds like pretty good definition – proud of that! Maybe I should write Janet and John Physics books…?

So now you can see the descriptions/quotes relating entropy to chaos as “relative order to chaos” eh?

For my purposes, let's just say that “minimum entropy is maximum order, or minimum randomness generated in a computer system”.

So how does entropy relate to computers? It's very important! It is used in cryptography, which relies on random numbers – so let's your browser connect securely to the internet for one!

Here's an interesting IT problem that many IT techs would not even think or know about:

https://major.io/2007/07/01/check-available-entropy-in-linux/

Check available entropy in Linux

By Major Hayden 7 Comments

Sometimes servers just have the weirdest SSL problems ever. In some of these situations, the entropy has been drained. Entropy is the measure of the random numbers available from /dev/urandom, and if you run out, you can’t make SSL connections. To check the status of your server’s entropy, just run the following:

# cat /proc/sys/kernel/random/entropy_avail

If it returns anything less than 100-200, you have a problem. Try installing rng-tools, or generating I/O, like large find operations. Linux normally uses keyboard and mouse input to generate entropy on systems without random number generators, and this isn’t very handy for dedicated servers.

That's ok if you already know where to look, but you could have tried some dirs or files to check out, as /dev/random and /dev/urandom are not readable and can cause a lock up if you cat them in byobu:

sudo find / -type d -name random

/proc/sys/kernel/random

or

sudo find / -type f -name *entropy*
/proc/sys/kernel/random/entropy_avail

So what do you get if you run that? On my quad core I get:

cat /proc/sys/kernel/random/entropy_avail

878

On my dual core I get:

cat /proc/sys/kernel/random/entropy_avail

184

That makes sense as the server is sat remotely running only a screensaver – no input data, mouse etc. compared to my quad core which I'm writing on.

Watch what happens to the entropy after I run a find operation remotely:

find . *pdf

cat /proc/sys/kernel/random/entropy_avail

206

Entropy increases – randomness increases.

Is there is a randomness specific log entry to find this issue, so you would know for sure that's the reason…? Seems there are terms you could grep for in OpenSSL, e.g:

sudo grep -r "PRNG not seeded" /*
Binary file /home/stevee/Downloads/Pinoir.img matches
Binary file /home/stevee/.cache/google-chrome/Default/Cache/3ea191a10d24916b_0 matches
Binary file /home/stevee/.cache/google-chrome/Default/Cache/8b0608bea81efde6_0 matches

or in the logs, try:

sudo grep -r "PRNG not seeded" /var/log/*

The term exists somewhere in a Raspbian file to find it in the Pinoir image above!

I expect the chrome pages to have it so they can inform the user of a browser connection failure...? Is it possible to read the actual cached document to find the text...? Ah no, these are just cached searches I did using that term...

sudo grep -r "PRNG not seeded" .*

Binary file ./.cache/google-chrome/Default/Cache/6a97a389cd22cd66_0 matches

https://www.openssl.org/docs/faq.html#USER1

1. Why do I get a "PRNG not seeded" error message?

Cryptographic software needs a source of unpredictable data to work correctly. Many open source operating systems provide a "randomness device" (/dev/urandom or /dev/random) that serves this purpose. All OpenSSL versions try to use /dev/urandom by default; starting with version 0.9.7, OpenSSL also tries /dev/random if /dev/urandom is not available.

On other systems, applications have to call the RAND_add() or RAND_seed() function with appropriate data before generating keys or performing public key encryption. (These functions initialise the pseudo-random number generator, PRNG.) Some broken applications do not do this. As of version 0.9.5, the OpenSSL functions that need randomness report an error if the random number generator has not been seeded with at least 128 bits of randomness.

So how did this Post research adventure come from byobu? Entropy is an option in the byobu terminal – e893 below - which you can run fully so the F9 keys work correctly on the remote machine using ssh over X11 as seen in the gkrellm Post:

ssh -tX dellmint byobu

Comments are closed.

Post Navigation