This is something I get caught out with from time to time.
You are not forced to reboot a Linux box as often as some other PC operating systems, for me this is good and bad.
It has been known for me to throw a machine together to solve a 'temporary' problem and not test that it returns to that same state after a reboot. It is all too easy to make the desired changes (iptables entries, NIC settings and routes) and not actually save them in init scripts. When your handy work silently turns from a 'temporary' solution into a permanent solution, and someone reboots the box... well you get the picture.
So if you can, always do a confidence reboot!
I often find myself searching the internet for things I know can be done, but can't quite remember how to do. This blog attempts to bring some of these cerebrally elusive items together along with information or opinions on subjects I find myself interested in or having to do as a Sys Admin.
Friday, 8 July 2011
Thursday, 26 May 2011
Generate random passwords, passphrases or keys
One of the things I never remember how to do without looking it up is creating a (pseudo) random string of hex characters. Recently I had need to create a new hex WPA pre shared key for a wireless network I was setting up.
Running the following command on a Linux box did the trick:
I know there is also a /dev/random device, so I looked up what the difference is. It seems /dev/random takes it's data from the kernel entropy pool, and if there is not enough data to serve you it will block waiting for more to become available. So If you replace /dev/random with /dev/urandom you may have to wait longer but your resulting key will be more random:
The xxd command simply converts the output of the /dev/random device to hexadecimal output.
Running the following command on a Linux box did the trick:
dd if=/dev/urandom bs=1 count=32 2>/dev/null | xxd -ps
I know there is also a /dev/random device, so I looked up what the difference is. It seems /dev/random takes it's data from the kernel entropy pool, and if there is not enough data to serve you it will block waiting for more to become available. So If you replace /dev/random with /dev/urandom you may have to wait longer but your resulting key will be more random:
dd if=/dev/random bs=1 count=32 2>/dev/null | xxd -ps
The xxd command simply converts the output of the /dev/random device to hexadecimal output.
Subscribe to:
Posts (Atom)