As a sysadmin, I need to generate lots of passwords and sometimes if you do so without a script the generated password becomes really easy to guess, and also is hard to build a safe password.
Because of this I use this script to generate pseudo-random passwords, is not an un-crackable method but solves the main problem.
You can put this code at the end of your .bashrc file, in order to make it like a system command, please do not remove the other lines in the file.
skyline ~ $ cd
skyline ~ $ vi .bashrc
##
## By: Alvaro Soto - alvaro@headup.ws
## http://headup.ws/node/18
##
## genpasswd: Generate a pseudo random password
## using a given length (default = 20).
##
genpasswd() {
local l=$1
[ "$l" == "" ] && l=20
tr -dc A-Z0-9_[%#?]a-z < /dev/urandom | head -c ${l} | xargs
}
##
##
##
skyline ~ $ . .bashrc
skyline ~ $ genpasswd
vie8e4d5naTCH70XvDyT
skyline ~ $ genpasswd 10
ts0QtdPe_x
skyline ~ $ genpasswd 5
5nw5Q
Is a less secure option to pwgen but it doesn't need a compiler.
skyline ~ $ emerge pwgen -s
Searching...
[ Results for search key : pwgen ]
[ Applications found : 1 ]
* app-admin/pwgen
Latest version available: 2.06-r1
Latest version installed: 2.06-r1
Size of files: 30 kB
Homepage: http://sourceforge.net/projects/pwgen/
Description: Password Generator
License: GPL-2
In action:
skyline ~ $ pwgen 20 --capitalize --symbols --numerals --secure 1
H2]}K/JGVs<523Xuv?"Y
skyline ~ $ pwgen 10 --capitalize --symbols --numerals --secure 1
JZ7a*&|:RP
skyline ~ $ pwgen 5 --capitalize --symbols --numerals --secure 1
`Aw8D