Skip to content

Instantly share code, notes, and snippets.

@jeremytregunna
Created May 9, 2017 04:58
Show Gist options
  • Select an option

  • Save jeremytregunna/fa1bbc1cf178ac5683f676cecb00742a to your computer and use it in GitHub Desktop.

Select an option

Save jeremytregunna/fa1bbc1cf178ac5683f676cecb00742a to your computer and use it in GitHub Desktop.
export PASS_RECIPIENT="you@your-gpg-identity.com"
export PASS_HOME=$HOME/.secret-or-some-other-place-you-want-to-keep-the-files
#!/bin/bash
if [ X"$1" = X"-h" ]; then
echo "Usage: pass-get <key>"
echo " Fetches and decrypts a password for the thing at key."
exit 0
fi
passwd_file=$PASS_HOME/$1.gpg
if [ -f $passwd_file ]; then
gpg -q --no-tty -r $PASS_RECIPIENT -d $passwd_file
else
echo "Couldn't find [ ${passwd_name} ]"
exit 1
fi
#!/bin/bash
if [ X"$1" = X"-h" ]; then
echo "Usage: pass-set <key> <pass>"
echo " Stores a password `pass` for a given key `key`."
exit 0
fi
if [ ! -d "$PASS_HOME" ]; then
mkdir -p $PASS_HOME
fi
passwd_file=$PASS_HOME/$1.gpg
read -sep "Enter password: " pw
echo
echo $pw | gpg -r $PASS_RECIPIENT -a -o $passwd_file -e -
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment