Generate random strings
(Another “piecemeal” post. Yes, I know: I should write more often.)
I cycle through one-off passwords (of varying lengths). To generate these, I use the following shell script:
#!/bin/bash usage() { echo "Usage: `basename $0` [length]" } [ $# -gt 1 ] && usage && exit 65 [ $# -eq 0 ] && len=8 || len=$1 strings /dev/urandom | grep -o '[[:alnum:]]' | head -n $len | tr -d '\n'; echo
To use:
$ ./genrand.sh 16 tFJNxyZk4EYaJiuz
And, no, that’s not my password. Or is it?
Read more:
- Simple script to switch IPs
- Writing a custom init script
- FizzBuzz
- Backing up WordPress database
- Using non-interactive FTP
No Comments Yet