generate random passwords with a bash function
This article shows you how to create Random passwords in the command line bash by adding a simple function to your bash.rc
as first we need to add this code to our .bash.rc
# Generate a random password # $1 = number of characters; defaults to 32 # $2 = include special characters; 1 = yes, 0 = no; defaults to 1 function randpass() { [ "$2" == "0" ] && CHAR="[:alnum:]" || CHAR="[:graph:]" cat /dev/urandom | tr -cd "$CHAR" | head -c ${1:-32} echo }
Once you stored it and read into memory you will be able to generate pw like this:
# randpass 16 0 MkyzmsLYJVIom8B9 # randpass 32 1 g&^>K1:40Y*&R$C(o;q!XS1,2j^_WvRr
enjoy!
No Comments have been Posted.