I use a script to decrypt my password for offlineimap, but somehow it's not working anymore ...

The file was encrypted with

gpg --symmetric password

For offlineimap I use this combination.

gpg --quiet --batch --no-tty --for-your-eyes-only --decrypt password.gpg

On Linux it's working like it should, but on FreeBSD I get the following error:

gpg --quiet --batch --no-tty --for-your-eyes-only --decrypt ~/.mail-accounts/xxxxxx/password.gpg
gpg: can't query passphrase in

batch mode gpg: decryption failed: bad key

Am I missing something?

gpg --version gpg (GnuPG) 1.4.19

Home: ~/.gnupg Supported algorithms: Pubkey: RSA, RSA-E, RSA-S, ELG-E, DSA Cipher: IDEA, 3DES, CAST5, BLOWFISH, AES, AES192, AES256, TWOFISH, CAMELLIA128, CAMELLIA192, CAMELLIA256 Hash: MD5, SHA1, RIPEMD160, SHA256, SHA384, SHA512, SHA224 Compression: Uncompressed, ZIP, ZLIB, BZIP2

I use the default gpg.conf without any changes.

It's not only working in offlineimap, also in my terminal and everywhere. ( on linux it's working)


Link to python file: https://github.com/tarruda/dot-files/blob/master/mail/offlineimap.py ( not me )

Same script found on stackexange. Encrypt OfflineIMAP Password

The call in offlineimap

remotepasseval = decrypt_password("[email protected]")

The idea behind is, that it's encrypted with "symmetric". When offlineimap is starting the python script an pinentry window opens and asks for the pw.

But the pinentry window isn't starting like on linux. On linux it is the same version only differ in Minor version.

In gpg 1.4.19 also the --batch option is available and has worked before, but i don't know what happens.

1 Answer 1


The --batch option was added in gpg v2. Prior to that, in v1, there is a --no-use-agent option which you might need if you're doing scripted operations.

That said, I don't understand how you're entering the key at time of decryption. ...? You're using --no-tty (which prevents gpg from asking you anything) but at least according to what you shared with us, you're not giving gpg a passphrase. That's a problem.

  • i edited my question with futher information
    – demonking
    Commented Apr 4, 2015 at 21:01
  • Sorry you was right, somehow i have made a mistake ... maybe a wrong ssh window or something like that. Because mismatch the gpg Versions.
    – demonking
    Commented Apr 5, 2015 at 20:10

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .