Difference between revisions of "Linux: gpg"

From RHS Wiki
Jump to navigation Jump to search
Line 35: Line 35:
 
==== Encrypt one recipient ====
 
==== Encrypt one recipient ====
 
  gpg --recipient <key ID> --encrypt <file>
 
  gpg --recipient <key ID> --encrypt <file>
 
+
== Encrypt with ascii output ==
 +
gpg --armor --encrypt --output ~/test.crypt --recipient redteam@bbva.com  ~/test.txt
 
==== Encrypt to multiple recipients ====
 
==== Encrypt to multiple recipients ====
 
  <nowiki>gpg --recipient 42FF42FF \
 
  <nowiki>gpg --recipient 42FF42FF \

Revision as of 06:18, 28 March 2018

GnuPG

Simetric Cipher

Encryption

gpg -c file.txt

we will be prompt for a password.
Or:

gpg -ca file.txt

If we want an ascii output

Decryption

gpg -d file.txt

we will be prompt for a password.

Asimetric Cipher

Generate keys

gpg --gen-key

List private keys

gpg --list-secret-keys

Export private key

gpg --export-secret-key -a "User Name" > private.key

Export public key

To file

gpg --output <destination_file.gpg> --export <public_key_ID>

To server

gpg --send-keys --keyserver pgp.mit.edu 18384645

Import public keys

From file

gpg --import <publickeyfile.gpg>

From server

gpg --keyserver pgp.mit.edu --recv-keys 18384645

Encrypt with a public key

List public keys

gpg --list-keys

Encrypt one recipient

gpg --recipient <key ID> --encrypt <file>

Encrypt with ascii output

gpg --armor --encrypt --output ~/test.crypt --recipient redteam@bbva.com  ~/test.txt

Encrypt to multiple recipients

gpg --recipient 42FF42FF \
    --recipient 12345678 \
    --recipient FEFEFEFE \
    --encrypt-files backup.tar

Decrypt with private key

comando gpg -d <encrypted_file>

Signing

Sign

gpg -u <private_Key_ID> --output <output_signed_file> --sign <file_to_sign>

Verify signature

gpg -d <signed_file>

or

gpg --verify <signed_file>

CheatSheet

Gpg_cheat_sheet.tar.gz