{"id":2906,"date":"2016-04-01T05:34:17","date_gmt":"2016-04-01T09:34:17","guid":{"rendered":"https:\/\/antipaucity.com\/?p=2906"},"modified":"2016-04-01T05:34:17","modified_gmt":"2016-04-01T09:34:17","slug":"improve-your-entropy-pool-in-linux","status":"publish","type":"post","link":"https:\/\/merikebi.warrenmyers.com\/?p=2906","title":{"rendered":"improve your entropy pool in linux"},"content":{"rendered":"<p>A few years ago, I ran into a <a href=\"http:\/\/serverfault.com\/q\/303935\/2321\">known issue<\/a> with one of the <a href=\"https:\/\/antipaucity.com\/tag\/hpsa\">products<\/a> I use that manifests when the {{Red Hat Linux}} server it&#8217;s running on has a low <a href=\"https:\/\/bugzilla.redhat.com\/show_bug.cgi?id=117218\">entropy<\/a> pool. And, as highlighted in that question, the steps I found 5 years ago didn&#8217;t work for me (turns out <a href=\"http:\/\/serverfault.com\/a\/316833\/2321\">modifying<\/a> the <code>t<\/code> parameter from &#8216;1&#8217; to &#8216;.1&#8217; <em>did<\/em> work (<code>rngd -r \/dev\/urandom -o \/dev\/random -f -t .1<\/code>), but I digress (and it&#8217;s no longer correct in {{CentOS}} 7 (the &#8216;t&#8217; option, that is))).<\/p>\n<p>In playing around with the Mozilla-provided SSL\u00a0<a href=\"https:\/\/mozilla.github.io\/server-side-tls\/ssl-config-generator\">configurator<\/a>, I noticed a line in the example {{SSL}} config that referenced &#8220;truerand&#8221;. After a little Googling, I found an opensource implementation called &#8220;<a href=\"http:\/\/www.finnie.org\/software\/twuewand\">twuewand<\/a>&#8220;.<\/p>\n<p>And a little more Googling about adding entropy, and I came across this interesting <a href=\"https:\/\/www.digitalocean.com\/community\/tutorials\/how-to-setup-additional-entropy-for-cloud-servers-using-haveged\">tutorial<\/a> from <a href=\"https:\/\/www.digitalocean.com\/?refcode=d197a961987a\">Digital Ocean<\/a> for &#8220;<a href=\"http:\/\/www.issihosts.com\/haveged\/downloads.html\">haveged<\/a>&#8221; (which, interestingly-enough, allowed me to <a href=\"http:\/\/serverfault.com\/a\/767413\/2321\">answer<\/a>\u00a0a 6-month-old question on Server Fault about <a href=\"http:\/\/cloudlinux.com\">CloudLinux<\/a>).<\/p>\n<p>Haveged &#8220;is an attempt to provide an easy-to-use, unpredictable random number generator based upon an adaptation of the <a href=\"http:\/\/www.irisa.fr\/caps\/projects\/hipsor\">HAVEGE<\/a> algorithm. Haveged was created to remedy low-entropy conditions in the Linux random device that can occur under some workloads, especially on headless servers.&#8221;<\/p>\n<p>And twuewand &#8220;is software that creates hardware-generated random data. It accomplishes this by exploiting the fact that the CPU clock and the RTC (real-time clock) are physically separate, and that time and work are not linked.&#8221;<\/p>\n<p>For workloads that require lots of entropy (generating {{SSL}} keys, {{SSH}} keys, {{PGP}} keys, and pretty much anything else that wants lots of random (or strong pseudorandom) seeding), the very real problem of running out of entropy (especially on headless boxes or {{virtual machines}}) is something you can face quite easily \/ frequently.<\/p>\n<p>Enter solutions like <a href=\"http:\/\/onerng.info\">OpenRNG<\/a> which are hardware entropy generators (that one is a USB dongle (see also this <a href=\"https:\/\/theexceptioncatcher.com\/blog\/2012\/11\/really-cool-things-ive-learned-this-week-r-random-numbers-java-hypervisiors-and-fan-maintenance\">skh-tec post<\/a>)). Those are awesome &#8211; unless you&#8217;re running in <a href=\"https:\/\/antipaucity.com\/tag\/cloud\">cloud<\/a> space somewhere, or even just a &#8220;traditional&#8221; {{virtual machine}}.<\/p>\n<p>One of the funny things about getting &#8220;random&#8221; data is that it&#8217;s actually very very hard to get. It&#8217;s easy to <em>describe<\/em>, but generating &#8220;truly&#8221; random data is incredibly difficult. (If you want to have an aneurysm (or you&#8217;re like me and think this stuff is unendingly fascinating), go read the Wikipedia entry on &#8220;<a href=\"https:\/\/en.wikipedia.org\/wiki\/Cryptographically_secure_pseudorandom_number_generator\">Cryptographically Secure Pseudo Random Number Generator<\/a>&#8220;.)<\/p>\n<p>If you&#8217;re in a situation, though, like I was (and still am), where you need to maintain a relatively high quantity of fairly decent entropy (probably close to CSPRNG level), use <code>haveged<\/code>. And run <code>twuewand<\/code> occasionally &#8211; at the very least when starting {{Apache}} (at least if you&#8217;re running HTTPS &#8211; which you should be, since it&#8217;s so <a href=\"https:\/\/antipaucity.com\/2016\/01\/06\/lets-encrypt-centos-6-truly-free-ssl\">easy<\/a> <a href=\"https:\/\/antipaucity.com\/2016\/02\/26\/automated-lets-encrypt-ssl-certificate-renewal-on-centos-7\">now<\/a>).<\/p>\n","protected":false},"excerpt":{"rendered":"<p>A few years ago, I ran into a known issue with one of the products I use that manifests when the {{Red Hat Linux}} server it&#8217;s running on has a low entropy pool. And, as highlighted in that question, the steps I found 5 years ago didn&#8217;t work for me (turns out modifying the t &hellip;<br \/><a href=\"https:\/\/merikebi.warrenmyers.com\/?p=2906\" class=\"more-link pen_button pen_element_default pen_icon_arrow_double\">Continue reading <span class=\"screen-reader-text\">improve your entropy pool in linux<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_hide_featured_image":false,"_jetpack_featured_image_duplicate_dismissed":0,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_post_was_ever_published":false},"categories":[41,45],"tags":[213,280,286,373,450,615,668,793],"keyring_services":[],"class_list":["post-2906","post","type-post","status-publish","format-standard","hentry","category-technical","category-tutorial","tag-cryptography","tag-encryption","tag-entropy","tag-haveged","tag-linux","tag-random","tag-security","tag-twuewand"],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=\/wp\/v2\/posts\/2906","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2906"}],"version-history":[{"count":0,"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=\/wp\/v2\/posts\/2906\/revisions"}],"wp:attachment":[{"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2906"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2906"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2906"},{"taxonomy":"keyring_services","embeddable":true,"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=%2Fwp%2Fv2%2Fkeyring_services&post=2906"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}