Encryption files with GPG without user intervention (batch)

Welcome to Linux Screw! If you're new here, you may want to subscribe our RSS feed.

I usually encrypt files with GPG with symmetric algorithms when I have to transmit files over insecure channel: for example I encrypt backup files stored at my USB stick and I'm sure that if it’s stolen or lost my files are in safety.

Encryption without user intervention can be used when you wish to perform automatic (runs with cron) backup procedure and protect backup files.

To encrypt file /tmp/file.tgz by symmetric AES algorithm (256 is a key lenght) with one command please use the following command:

echo password | gpg --batch -q --passphrase-fd 0 --cipher-algo AES256 -c /tmp/file.tgz

Previous command will create file.tgz.gpg that can be extracted automatically by next one:

echo password | gpg --batch -q -o /tmp/file.tgz --passphrase-fd 0 --decrypt /tmp/file.tgz.gpg

Share This
Related posts:
Create Linux user with password
Copy files from Windows or Mac to Linux safely
Secure shell (ssh) connection without password
Quick shell change for user in Unix or Linux
Bash shell FAQ
 
 
 
Your Ad Here


1 Response to “Encryption files with GPG without user intervention (batch)”


  1. 1 thehurley

    Thank you, just what I was looking for!

Leave a Reply

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word