In my line of work, I often need to generate random passwords for new accounts. I always find it kind of annoying to have to think these things up. Every now and then I even need to created many at once.
Here is a quick way to generate as many random passwords as you want just using BASH:
for ((i=0; i<10; i=i+1)); do head -c 8 /dev/urandom | uuencode -m - | head -n 2 | tail -n 1 | sed s/\=//; done
Simply adjust the ‘i’ variable in the for loop to change how many passwords you want. The ‘-c’ on the first head statment can be changed to adjust the size of each password that is created. The real nice thing about this little snipet, is that it outputs to stdout…this makes it a cinch to send to output on to something else.
For an added twist, you can use this line to have the generated passwords contain more punctuation marks:
for ((i=0; i<10; i=i+1)); do head -c 8 /dev/urandom | uuencode - | head -n 2 | tail -n 1 | sed s/\`// | sed s/\(//; done
With this one, make sure you filter out any special characters that aren’t allowed in your new passwords.