How to easily encrypt/decrypt a file in Linux with gpg

Discussion in 'all things UNIX' started by lotuseclat79, Jun 6, 2016.

  1. lotuseclat79

    lotuseclat79 Registered Member

    Joined:
    Jun 16, 2005
    Posts:
    5,094
  2. mirimir

    mirimir Registered Member

    Joined:
    Oct 1, 2011
    Posts:
    6,028
    Yes, very easy:

    gpg -e -o foo.gpg foo.txt

    It will ask for KeyID(s) to encrypt to.
     
  3. Anonfame1

    Anonfame1 Registered Member

    Joined:
    May 25, 2016
    Posts:
    193
    I find it so much easier to just create an image container and use luks. Its also better if you need to protect against someone gaining access to your drive. Sure, the gpg will stop them, but if you have an SSD or journaling file system cant they just pull the deleted foo.txt from disc? Deleting only unallocates the space as used.. Even shred wont necessarily help you if you have a journaled filesystem since the journal might screw you. Youd have to run ext2 on a data partition and use shred on the foo.txt after making foo.gpg. On an SSD as I understand it even this may not be enough.

    Am I wrong here? Maybe im missing something..
     
  4. Palancar

    Palancar Registered Member

    Joined:
    Oct 26, 2011
    Posts:
    1,591
    As a security guy I would always recommend complete sector by sector encryption. I don't care how secure an encrypted file is, if an adversary has access to the OS that created/uses it, then its a NO WAY for me. There is definitely a place for encrypted files, but in my view there is NEVER a place for an unencrypted OS or data archive. Just my take, while many may differ.
     
  5. oliverjia

    oliverjia Registered Member

    Joined:
    Jul 21, 2005
    Posts:
    1,517
    I can see the encrypted gpg file being particularly suitable for sending files over the Internet, either via email or cloud. So, there is a market for gpg encrypted files/directories.

    For local encryption, I agree, better to use LUKS. If not FDE with LVM, at least encrypt /Home.
     
  6. Palancar

    Palancar Registered Member

    Joined:
    Oct 26, 2011
    Posts:
    1,591

    Ditto!!
     
Loading...