Creating Pseudo-Random Passwords in Linux
Add this to your ~/.bashrc:
genpass() {
local p=$1
[ "$p" == "" ] && p=16
tr -dc A-Za-z0-9_ < /dev/urandom | head -c ${p} | xargs
}
To generate the passwords, just type:
$ genpass
Examples:
$ genpass
dIBObynGX9epYogz
$ genpass 8
c_yhmaXt
$ genpass 12
FZI2wz2LzyVQ
$ genpass 14
ZEfgQvpY4ixePt
Written by bt3gl
Related protips
2 Responses
For Mac OSX (at least Yosemite), I had to do the following to make it work (and expand what it could do):
genpass() {
local p=$1
[ "$p" == "" ] && p=16
LCCTYPE=C tr -dc A-Za-z0-9!\@#\$\%^&*()-+= < /dev/urandom | head -c ${p} | xargs
}
over 1 year ago
·
debian & friends
apt-get install apg
suse & friends
yum install apg
osx
brew install apg
over 1 year ago
·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Linux
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#