Skip to content

Instantly share code, notes, and snippets.

@ClimenteA
Last active July 8, 2026 09:03
Show Gist options
  • Select an option

  • Save ClimenteA/98ace05bf87b7526d731fce4e6a6d49f to your computer and use it in GitHub Desktop.

Select an option

Save ClimenteA/98ace05bf87b7526d731fce4e6a6d49f to your computer and use it in GitHub Desktop.
Generate strong secrets from linux terminal

Generate secrets

nano ~/.bash_aliases

Paste this func:

randstr() {
    # Use the first argument ($1) if provided, otherwise default to 48
    local length=${1:-48}
    tr -dc 'A-Za-z0-9' < /dev/urandom | head -c "$length"; echo
}

Then Ctrl+O to save and Ctrl+X to save.

source ~/.bash_aliases

After this you can use it from terminal like:

randstr

or

randstr 64  << here 64 is the number of chars to output
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment