Skip to content

Instantly share code, notes, and snippets.

@tjstebbing
Last active May 8, 2023 12:25
Show Gist options
  • Save tjstebbing/ecbadf6bd2fa58660460220fc685ad73 to your computer and use it in GitHub Desktop.
Save tjstebbing/ecbadf6bd2fa58660460220fc685ad73 to your computer and use it in GitHub Desktop.

+++ categories = ['hax'] date = '2021-08-12' description = 'Generate deterministic passwords on the command line' slug = 'deterministic-passwords' title = 'Generate deterministic passwords on the command line' +++

Simple method for creating deterministic passwords on the commandline

This is a simple shell function that uses openssl to create a unique password for any website / service using a master password salt.

Usage:

> pass twitter.com
Password:  
_1vvfamnYcHegiXn0uAL2n1. is now in your clipboard for twitter.com.
>

Your twitter password is now in your clipboard ready to paste.

Install:

Add this function to your .bashrc or .zshrc file. On MacOS replace xclip with pbcopy.

zsh on linux:

pass() { _p=$(openssl passwd -1 -salt $(read -s '_pass?Password: ' && echo $_pass) "$1" | awk -F$ '{print "_1"$NF}') && echo "$_p is now in your clipboard for $1." && echo $_p | xclip -selection clipboard }

bash on linux:

pass() { _p=$(openssl passwd -1 -salt $(read -s -p 'Password: ' _pass && echo $_pass) "$1" | awk -F$ '{print "_1"$NF}') && echo "$_p is now in your clipboard for $1." && echo $_p | xclip -selection clipboard }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment