Advertisement
thioshp

Export a GPG Key Details

Jul 10th, 2020
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. # Export or Dump a GPG/PGP key's details to a .info file
  4. # GPG keys have an .gpg as the file extension
  5. # NB: You must have `mutt` installed in order to use its `mutt_pgpring` script
  6.  
  7. pname=`basename "$0"`
  8.  
  9. KEY="$1"
  10.  
  11. # Show colored message
  12. showmsg ()
  13. {
  14. echo $'\033[35m'"$@" 1>&2 $'\033[0m';
  15. }
  16.  
  17. # Show errors
  18. error ()
  19. {
  20. echo $'\033[31m'"ERROR: $pname: $@" 1>&2 $'\033[0m';
  21. shift;
  22. }
  23.  
  24. # Exit if NO GPG KEY FILE is given
  25. if test -z "$KEY"
  26. then
  27. error "You must specify a GPG/PGP KEY file";
  28. showmsg "SYNTAX: $pname <KEYFILE.gpg>";
  29. exit 1;
  30. else
  31. mutt_pgpring -k "$KEY" | tee "$KEY".info;
  32. showmsg "SUCESS: $KEY dumped to $KEY.info"
  33. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement