pwgen
Installation
_$: apt install pwgen
Usage
With no ambiguous characters such as 0-O or 1-l:
_$: pwgen -B 20 1
xoofah7caeJei4Phooh3
A machine password, hard to memorize:
_$: pwgen -s 20 1
1dEgPAZCDay7anACno55
Several passwords, one per line:
_$: pwgen -1 -s 20 5
s7bd3NopMgSZBtMTT58t
5kqK0e54J4c3AI0YwAsB
NRgJySqoGAtoKWz1ntJz
R8ljsTQPmNoh7OxEft6X
1ysZ7XoQOvjvqmK8CO5G
Alternative password generator with tr
For one-use cases, we can use the following one liner:
_$: tr -dc A-Za-z0-9 < /dev/urandom | head -c 16 ; echo
And if we are going to use it more than once, we can create a shell script:
/usr/sbin/password-generator:
-----------------------------
DEFAULT_LENGTH=32
length=$1
[ "$length" == "" ] && length=${DEFAULT_LENGTH}
tr -dc A-Za-z0-9 < /dev/urandom | head -c ${length}
echo
_$: chmod +x /usr/sbin/password-generator
_$: password-generator 16
MkPmA1OWf4f9OdRy