Random password in Linux bash

linux
ubuntu
bash
Category Software and digital electronics / Computer Theory
2024-12-21 15:42

Is this possible to create a random password in my Ubuntu bash?

I need the password to be capital/small/number/symbol.

The length of password should be exactly 66.

add comment
Answered by robin
2024-12-22 02:07

Yes, it is possible:

< /dev/urandom tr -dc 'A-Za-z0-9@#$%^&*()_+-=~`[]{};:,.<>?/|\\' | head -c 66; echo

The /dev/urandom is a source of random data in Linux. The tr filters specific characters from your set. And head will limit the characters to your specific length.

Please note that, /dev/urandom is not cryptographically secure.

For cryptographically secure random data generation, use openssl as follows:

openssl rand -base64 48 | tr -dc 'A-Za-z0-9@#$%^&*()_+-=~`[]{};:,.<>?/|\\' | head -c 66
add comment
×

Login

No account?
Terms of use
Forgot password?