Last active
August 18, 2019 06:46
-
-
Save zaletniy/a2704d01a439dbd282b18a002da64086 to your computer and use it in GitHub Desktop.
Password Exporter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
Author
zaletniy
commented
Jul 12, 2019
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment