Skip to content

Instantly share code, notes, and snippets.

@apg
Created January 11, 2012 14:42
Show Gist options
  • Save apg/1594957 to your computer and use it in GitHub Desktop.
Save apg/1594957 to your computer and use it in GitHub Desktop.
#!/bin/bash
# passadd
if [ -z "$PASSFILE" ]
then
echo "PASSFILE doesn't exist"
exit 1
fi
if [ $# -ne 1 ]
then
echo "usage: passadd [name]"
exit 1
else
t=$(tempfile) || exit
trap "shred -u -n 10 -z '$t'" EXIT
gpg --no-for-your-eyes-only -o $t -d $PASSFILE
read -s -p "password to save: " passwd
echo
echo "$1:$passwd" >> $t
gpg -o $PASSFILE -c $t
shred -u -n 10 -z "$t"
trap - EXIT
exit
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment