Search code examples
bashencryptiongnupg

gpg batch-encryption with my own key without keyboard interaction


I need to save a couple of files on a webserver and would like to have them encrypted with my own public key before.

Therefore I just wrote a simple bash-script:

#!/bin/bash  

ls *.7z > filelist.txt

while read currow
do
 gpg --encrypt -ac --recipient myemail@example.com $currow

done < filelist.txt
rm filelist.txt

But this doesn't really work. For each file I get this dialog where I have to enter my password (twice).

pinentry

How can I avoid this? Thank you


Solution

  • You are using the -c option, which is the short equivalent of the long --symmetric option. You are not using public key cryptography by using this option, which is why you are asked for a password.

    Try changing -ac to -a in your script above.