Compress and encrypt files and folders
W. F.
webbiforetag at proton.me
Fri May 29 15:47:11 CEST 2026
Hello,
I'm in need of compressing and encrypting both individual files, but also folders in my Linux environment.
Suppose I have a file called "schema.sql" that I need to compress and encrypt, or a folder called "daily_backup" which consists of 5 files and 3 subdirectories (each containing various files). How would you recommend I compress and encrypt this data?
I want to use a passphrase for encryption - and not a key file.
Currently, I have configured GnuPG using a configuration file with the following:
$ nano ~/.gnupg/gpg.conf
cipher-algo AES256
digest-algo SHA512
cert-digest-algo SHA512
s2k-cipher-algo AES256
s2k-digest-algo SHA512
s2k-mode 3
s2k-count 65011712
compress-algo none
throw-keyids
no-emit-version
no-comments
no-symkey-cache
disable-cipher-algo 3DES
disable-cipher-algo CAST5
disable-cipher-algo BLOWFISH
$ chmod 700 ~/.gnupg
$ chmod 600 ~/.gnupg/gpg.conf
And so far I've tried encrypting a single file using a passphrase like so:
$ echo "hello world" > file.txt
$ gpg -c -o encrypted.dat --batch --passphrase "Password123!" file.txt
$ rm file.txt
$ gpg --batch --yes --passphrase "Password123!" -d -o file.txt encrypted.dat
$ cat file.txt
I can also use it interactively by omitting "--passphrase".
I'm a beginner when it comes to encryption and for me it's important that the encryption I use is secure enough to withstand brute force attacks, so please help me out by configuring the GPG configuration file properly. I don't know if my settings are considered bad practice in 2026.
I also need a way to compress an entire directory. And preferably also hide all file names and metadata.
I want the encrypted file to show as little information as possible (dates, groups, user, filenames, metadata, etc).
I suppose I need to use "tar" and pipe it to GPG.
Please show me your commands using best practices in 2026, using a passphrase (and not a key file).
Thank you!
Best Regards
Wilhelm Futtiger
More information about the Gnupg-users
mailing list