A tiny, POSIX-friendly password generator written as a single bash script. Fast, dependency-free, and designed for secure random output from /dev/urandom.
- Make executable:
chmod +x ./rpw - Run:
./rpw - Run with presets:
./rpw --easy | --medium | --hard
-l <length>Set password length (default: 32)-r <count>Number of passwords to generate (default: 1)-o <file>Append outputs to file instead of stdout-o <file>Append outputs to file instead of stdout-f <format>,--format=<format>Output format: plain (default), json, csv
## Flags
-sInclude symbols in the charset-cChallenge/response mode (hex charset; for YubiKey-like flows)-nNumbers only-LLowercase alphanumeric only-NRequire at least one digit-ARequire at least one alphabetic character (script uses -A)-SRequire at least one symbol-b,--clipboardCopy last generated password to clipboard (pbcopy/xclip/xsel) if available; does not fail if clipboard tool missing-h,--helpShow help--easyPreset: easy (short, lowercase)--mediumPreset: medium (balanced)--hardPreset: hard (symbols + stricter requirements)--yubi-challengePreset: yubi-compatible challenge (hex)
Notes:
- When writing to a file (-o) or copying to the clipboard (-b/--clipboard), the script will not echo passwords to stdout for safety. Use -o / -f to capture output instead.
- Default:
./rpw - Simple 8-char with all classes:
./rpw -l 8 -N -A -S - Repeat 5 challenge responses:
./rpw -c -r 5 - Hard preset with custom length:
./rpw --hard -l 24 - Save two easy passwords:
./rpw --easy -r 2 -o passwords.txt
- Uses LC_ALL=C with tr for locale-safe byte filtering from /dev/urandom.
- Script enforces minimum length when "must-have" flags are set.
- No external dependencies: just bash, tr, head, and /dev/urandom.
- Small repo: keep changes minimal and shellcheck-friendly.
- Consider adding tests (bats/shunit2) and CI lint (shellcheck) if contributing larger changes.