Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

What's the most popular command to do such things as encrypting a file or directory in terminal in Linux?

share|improve this question

4 Answers 4

I think it would be gpg. The syntax for files and directories differs though.

Encryption

For files(outputs filename.gpg):

gpg -c filename

For dirs:

gpg-zip -c -o file.gpg dirname

Decryption

For files(outputs filename.gpg):

gpg filename.gpg

For dirs:

gpg-zip -d file.gpg

Edit: Corrected as @Mk12 pointed out the mistake of compression/decompression for encryption/decryption.

share|improve this answer
    
Shouldn't that be "Encryption" and "Decryption"? –  Mk12 Jul 27 '12 at 18:41
    
Thanks @Mk12. I must have been distracted to the utmost. :P –  celebdor Aug 22 '12 at 15:27
    
Nobody has said how to encrypt a directory. –  chovy Oct 18 at 8:50
    
@chovy Not that above it says: For dirs: gpg-zip -c -o file.gpg dirname –  celebdor Oct 20 at 10:33
    
@celebdor missed that one. thanks. edit: that doesn't work for me. I get some weird encrypted output when I decrypt the file. –  chovy Oct 24 at 15:29
  • with openssl

openssl des3 -salt -in unencrypted-data.tar -out encrypted-data.tar.des3

Decrypt:

openssl des3 -d -salt -in encrypted-data.tar.des3 -out unencrypted-data.tar

  • encrypt with AES

aescrypt -e -p password file.jpg

Decrypt:

aescrypt -d -p password file.jpg.aes

share|improve this answer
1  
+1 for showing how to do it with openssl, which is most likely available out-of-the-box. –  DevSolar Aug 22 '12 at 15:39

Try GnuPG.

To encrypt: gpg -c filename

To decrypt: gpg filename.gpg

share|improve this answer

I personally use aescrypt mostly.

      aescrypt -e "File" 

and decrypt:

      aescrypt -d "File"

Or there's mcrypt:

      mcrypt "File" 

and decrypt:

      mcrypt -d "File"

And for a file, I suggest tar'ing the dir, and encrypting that. Then after unencrypting, just untar the file:

      tar -cf "Dir.tar" Dir/

and to untar

      tar -xf "Dir.tar"
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.