Return to site

Random Password Cheat Sheet

How to create random passwords from the command line

· random password,command line,password,cheat sheet,windows

ONE-LINER

LINUX/MacOS

# openssl rand -base64 20
Example) YnKFUmVPYzQDrK3QT5NZ0Wh51kMBaXw=

# pwgen 10
Example) giepahl3Oy

# gpg --gen-random --armor 1 14 

Example) 1Hs0a5BYKlcRY0wvPy8=

# uuidgen | tr -d '\n'

Example) 9C3CF72D-175D-41D6-ADC1-173D784CFBD7

WINDOWS

PS> $Password = ([char[]]([char]33..[char]95) + ([char[]]([char]97..[char]126)) + 0..9 | sort {Get- Random})[0..8] -join ''
Example) Fj-Rs!4p2z

PS> dir C:\Windows\*.* | Get-Random | Get-FileHash -Algorithm SHA1

Example) 819AABA1653415766D4A6B0F5F89833F4E40AA27

SCRIPTABLE

LINUX/MacOS

@Echo Off
Set /A Rnd=%Random%
Set PassLenght=10
SetLocal EnableDelayedExpansion EnableExtensions
Set TotalChars=72
Set CharSet=0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWQYZ()_+-*!@#$
:Loop
Set /A Rnd=%TotalChars%*%Random%/32768
Set Pswd=!CharSet:~%Rnd%,1!%Pswd%
Set /A PassLenght-=1
If %PassLenght% GTR 0 GoTo Loop
@echo %Pswd%
pause

WINDOWS

........

Have more ideas on how to generate random passwords from the command line? @netmux on Twitter and let us know :)