Generate password and print to stdout?

Alexandre Pujol alexandre at pujol.io
Tue Nov 14 15:47:11 CET 2017


Hi all,

I use a simple bash function that generates password using /dev/urandom,
and tr the exact same way pass does it.

Then I have a few aliases to easily generate password/pin...

As example:
_pw() {
	local characters="${1}" length="${2:-25}"
	bash -c 'read -r -n "$0" pass < <(LC_ALL=C tr -dc "$1" < /dev/urandom)
&& echo $pass' $length $characters
}

alias pw='_pw "[:graph:]"'
alias pw2='_pw "[:alnum:]"'
alias pin='_pw "[:digit:]"'


On 14/11/17 13:58, Jason Banfelder wrote:
> One might also use something like…
> 
>    gpg --armor --gen-random 1 20
> 
This is actually not a good things because you are generating only
base64 password.


> On Tue, Nov 14, 2017 at 3:00 PM Till Schäfer
> <till2.schaefer at tu-dortmund.de <mailto:till2.schaefer at tu-dortmund.de>>
> wrote:
> 
>     Hi,
>     there is a standard unix tool for this purpose: pwgen
> 
>     Regards,
>     Till
pass dropped the use of pwgen since pass 1.7 for security purposes.


Regards,
Alex


More information about the Password-Store mailing list