Skip to content

Instantly share code, notes, and snippets.

@zaletniy
Last active August 18, 2019 06:46
Show Gist options
  • Save zaletniy/a2704d01a439dbd282b18a002da64086 to your computer and use it in GitHub Desktop.
Save zaletniy/a2704d01a439dbd282b18a002da64086 to your computer and use it in GitHub Desktop.
Password Exporter
#!/bin/bash
# Usage:
# passe secret_alias recepient
#
# Example:
# passe jira_admin_password Ian
#
# Waiting when it will be replaced with
# age https://docs.google.com/document/d/11yHom20CrsuX8KQJXBBw04s80Unjv8zCg_A7sPAX_9Y/edit#
ALIAS=$1
RECEPIENT=$2
echo "Please input data to send ?"
echo "========================="
read -s SECRET_DATA
echo "OK"
echo "Matching recepients:"
echo "===================="
gpg -k | grep $RECEPIENT -B 1 --color
echo "$SECRET_DATA" > $ALIAS
gpg -a -r $RECEPIENT --encrypt $ALIAS
echo "Encrypted"
gpg --detach-sig ${ALIAS}.asc
echo "Signed"
echo "Files" > README.txt
echo "=====" >> README.txt
echo "${ALIAS}.asc - PGP encrypted secret in ASCII format " >> README.txt
echo "${ALIAS}.asc.sig - PGP detached signature " >> README.txt
echo "" >> README.txt
echo "For signature verification run:" >> README.txt
echo "===============================" >> README.txt
echo "gpg --verify ${ALIAS}.asc.sig ${ALIAS}.asc" >> README.txt
echo "" >> README.txt
echo "For secret decryption run:" >> README.txt
echo "==========================" >> README.txt
echo "gpg --decrypt ${ALIAS}.asc" >> README.txt
echo "or" >> README.txt
echo "gpg -o <output_file_name> --decrypt ${ALIAS}.asc" >> README.txt
rm ${ALIAS}
zip ${ALIAS}.zip ${ALIAS}.asc* README.txt
rm ${ALIAS}.asc* README.txt
@zaletniy
Copy link
Author

isviridov@magicbook:~/projects/new_work$ passe testpassword Paul
Please input data to send ?
=========================
OK
Matching recepients:
====================
      A75156DEF2707AD39CDF2B**
uid           [  full  ] Paul * <pa***4@gmail.com>
Encrypted
gpg: using "**B6297C36EF056FF858E***" as default secret key for signing
Signed
updating: testpassword.asc (deflated 21%)
updating: testpassword.asc.sig (stored 0%)
updating: README.txt (deflated 56%)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment