The generation of password in Unix/Linux

Each of us is always faced with the problem is to generate the password. More precisely, in order to invent him. For me, this is not a problem, but for example to use a password in bash script — need to know how to generate a “complex” password. By this, I am in this thread, I decided to collect different examples of how you can generate a password. Went…

$ tr -dc [:graph:] < /dev/urandom | head -c 32| xargs echo; {E&7#I^te+G4qN(_]ma2+}fYtk&LZcXV 

Another kind of team:

$ tr -dc [email protected]#$%^&*()-+= < /dev/urandom | head -c 32 | xargs

Note: these commands work in Linux! To work in Unix, for example in MacOS, do:

$ LC_CTYPE=C tr-dc [email protected]#$%^&*()-+= < /dev/urandom | head -c 32 | xargs

Still a team:

$ LC_ALL=C; cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold-w 32 | head -n 1

If got error:

tr: Illegal byte sequence

The solution will be is to add “export LC_ALL=C;” before the command, for example:

$ export LC_ALL=C; head-c 500 /dev/urandom | tr -dc "A-Za-z0-9"

Consider another example:

$ tr -dc '[:alnum:]' < /dev/urandom | dd bs=4 count=8 2>/dev/null | xargs echo; 9kKbjIQRqQLpnSzRJT1n6wiXivqJzCMh

You can run the command like this:

$ cat /dev/urandom | tr -dc 'a-z0-9' | head -c 32| xargs echo; 9tko490pwdb0jmltu6i4rtxetdtq0mhp

You can:

$ cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold-w 32 | head -n 1

Another variation:

$ head-c 16 /dev/urandom | md5sum | head -c 32| xargs echo;

You can use base64 in conjunction with the commands:

$ base64 /dev/urandom | tr-d '/+' | head -c 32 | tr '[:upper:]' '[:lower:]' | xargs echo; jryupsa3scgrpy6o1xwob3rhjxqz0q3v

Or:

$ pwgen -s 10 1

The same command is:

$ head-c24 < <(tr-dc '41-176' < /dev/urandom) | xargs echo; {u*Ff&1'X~.qz)sPjVxt0

Or:

$ head-c24 < /dev/random | base64

and:

$ echo $(cat /dev/urandom | tr -dc [:print:] | tr-d '[:space:]4247134' | fold-w 64 | head -n 1)

More:

$ openssl rand -base64 4

Or:

$ openssl rand -hex 100

or:

$ openssl rand -base64 500 | tr-dc 'a-zA-Z0-9' | fold-w 128 | head -n 1

And:

$ xxd-l16 -ps /dev/urandom

In Linux you can run:

$ cat /proc/sys/kernel/random/uuid

That’s all the article “Generation of password in Unix/Linux” is completed.

Source: linux-notes.org

(Visited 2 times, 1 visits today)