Advertisement
opexxx

GPG commands.txt

Aug 12th, 2013
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.32 KB | None | 0 0
  1. GPG commands
  2.  
  3. This is a summary of GPG commands that I've found useful.
  4. Listing keys
  5.  
  6. # List public keys:
  7. gpg --list-keys
  8.  
  9. # List private keys:
  10. gpg --list-secret-keys
  11.  
  12. Exporting keys
  13.  
  14. USERNAME="User name"
  15. PUBKEY=public.key
  16. PRIKEY=private.key
  17.  
  18. # Export public keys:
  19. gpg --export -a $USERNAME > $PUBKEY
  20.  
  21. # Export private key:
  22. gpg --export-secret-key -a $USERNAME > $PRIKEY
  23.  
  24. Importing keys
  25.  
  26. USERNAME="User name"
  27. PUBKEY=public.key
  28. PRIKEY=private.key
  29. FINGERPRINT=fingerprint.txt
  30.  
  31. # Importing public key:
  32. gpg --import $PUBKEY
  33.  
  34. # Importing private key:
  35. gpg --allow-secret-key-import --import $PRIKEY
  36.  
  37. # Generate the fingerprint:
  38. gpg --fingerprint > $FINGERPRINT
  39.  
  40. Encrypting and decrypting
  41.  
  42. FILEIN=file.txt
  43. FILEOUT=$FILEIN.gpg
  44.  
  45. # Encrypt a file (symmetric cipher using a passphrase):
  46. gpg -c $FILEIN
  47.  
  48. # Decrypt a file:
  49. gpg $FILEOUT
  50.  
  51. Encrypting and decrypting (using openssl)
  52.  
  53. DIRECTORYIN=directory
  54. FILEIN=file.txt
  55. FILEOUT=directory.tar.gz.aes
  56. FILEIN=directory.tar.gz.aes
  57.  
  58. # Encrypt a zipped directory using ssl
  59. tar -zcf - $DIRECTORYIN | openssl aes-256-cbc -salt -out $FILEOUT
  60.  
  61. # Decrypt a zipped directory using ssl
  62. openssl aes-256-cbc -d -salt -in $FILEIN | tar -xz -f -
  63.  
  64. # Generate password
  65. gpg --gen-random 2 16 | base64
  66.  
  67. Links
  68.  
  69.    http://irtfweb.ifa.hawaii.edu/~lockhart/gpg/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement