pgp.sh 883 B

12345678910111213141516171819202122232425262728293031323334353637
  1. #############################################################################
  2. #
  3. # PGP Functions
  4. #
  5. #############################################################################
  6. function pgp-encrypt()
  7. {
  8. tar -zcv $1 | gpg2 --encrypt -r ${2:-alex@matevi.sh} - > $1.tar.gz.gpg;
  9. }
  10. function pgp-decrypt()
  11. {
  12. gpg2 --decrypt $1 | tar -zxvf -;
  13. }
  14. function gpg-stash-mount()
  15. {
  16. (cd ~/.configs/gpg-stash && ./run.sh -d)
  17. }
  18. function gpg-stash-unmount()
  19. {
  20. (cd ~/.configs/gpg-stash && ./run.sh -r)
  21. }
  22. function switch-yubikeys()
  23. {
  24. # Running any decrypt, auth or sign will now ask you to insert Yubikey2
  25. # To switch to Yubikey1 at any time run this script to force GPG
  26. # to repoint the key stubs to the inserted Yubikey
  27. read -p "Insert the Yubikey you want to use .... " ignore
  28. echo "Switching GPG to backup Yubikey ..."
  29. gpg-connect-agent "scd serialno" "learn --force" /bye
  30. }