top of page

COURSE 1  - 3.3.3.2. PGP: Encryption of file (Terminal)

<   >

QUICK INFO:

  • Asymmetric encryption: key pair (Private, Public); the recipient sends his Public key to the sender

  • Command to import a Public Key:

    • gpg --import KEY_FILE
  • Command to encrypt a file for a recipient:

    • gpg  --sign --local-user KEY_ID --encrypt --armor --recipient  EMAIL_OF_RECIPIENT --recipient SENDER_EMAIL --output  NAME_ENCRYPTED_FILE.txt.asc NAME_DECRYPTED_FILE.txt
  • Command to read the encrypted file on screen:

    • cat NAME_ENCRYPTED_FILE.txt.asc
  • To decrypt a file encrypted with our Public Key:

    • gpg --decrypt NAME_ENCRYPTED_FILE.txt.asc > NAME_DECRYPTED_FILE.txt
  • Command to read the decrypted file on screen:

    • cat NAME_DECRYPTED_FILE.txt

How to encrypt/decrypt a file using the Linux command line (Terminal)

bottom of page