Difference between revisions of "Linux: gpg"

From RHS Wiki
Jump to navigation Jump to search
Line 31: Line 31:
  
 
=== Encrypt with a public key ===
 
=== Encrypt with a public key ===
 +
==== List public keys ====
 +
gpg --list-keys
 +
==== Encrypt one recipient ====
 
  gpg --encrypt --recipient <key ID> <file>
 
  gpg --encrypt --recipient <key ID> <file>
 +
==== Encrypt to multiple recipients ====
 +
<nowiki>gpg --recipient 42FF42FF \
 +
    --recipient 12345678 \
 +
    --recipient FEFEFEFE \
 +
    --encrypt-files backup.tar</nowiki>
 +
 
=== Decrypt with private key ===
 
=== Decrypt with private key ===
 
  comando gpg -d <encrypted_file>
 
  comando gpg -d <encrypted_file>

Revision as of 15:23, 24 April 2016

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 --encrypt --recipient <key ID> <file>

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