Linux-HA Logo

How to generate authkeys automatically

Since the key in /etc/ha.d/authkeys file never has to be typed by a human being, it is not necessary for it to be in any way mnemonic or memorable. As a result a long, randomly generated key is a good choice.

The following line of shell script will generate such a key:

cat <<-!AUTH >/etc/ha.d/authkeys
        # Automatically generated authkeys file
        auth 1
        1 sha1 `dd if=/dev/urandom count=4 2>/dev/null | md5sum | cut -c1-32`
!AUTH

Or you can download a complete command which will do this[1] quite nicely.

Or for SHA1:

dd if=/dev/urandom count=4 2>/dev/null | openssl dgst -sha1

References

[1]http://www.linux-ha.org/_cache/GeneratingAuthkeysAutomatically__gen_authkeys.sh


This information provided courtesy of the Linux-HA project at http://linux-ha.org/