How to tell Mutt to ask for a gpg passphrase

gpgmutt

I'm slowly migrating to mutt after years of Thunderbird and stumped by gpg. I have Mutt signing messages by default, but I don't get asked for a passphrase and then the message fails:

gpg: can't query passphrase in batch mode
gpg: skipped "53453F2E": bad passphrase
gpg: signing failed: bad passphrase
Press any key to continue...

How do I get Mutt to ask me for a passphrase if it needs one to sign messages?

Best Answer

What is your configuration? I used a tutorial long ago (sorry, I don't see it now) to get this configuration:

# $Id: .gpg-muttrc,v 1.1 2004/01/08 00:22:40 tom Exp $
# mutt commands for GPG
set pgp_sign_as=0xF7E48EDB
set pgp_decode_command="gpg %?p?--passphrase-fd 0? --no-verbose --batch --output - %f"
set pgp_verify_command="gpg --no-verbose --batch --output - --verify %s %f"
set pgp_decrypt_command="gpg --passphrase-fd 0 --no-verbose --batch --output - %f"
set pgp_sign_command="gpg --no-verbose --batch --output - --passphrase-fd 0 --armor --detach-sign --textmode %?a?-u %a? %f"
set pgp_clearsign_command="gpg --no-verbose --batch --output - --passphrase-fd 0 --armor --textmode --clearsign %?a?-u %a? %f"
set pgp_encrypt_only_command="/usr/lib/mutt/pgpewrap gpg --batch --quiet --no-verbose --output - --encrypt --textmode --armor --always-trust --encrypt-to $pgp_sign_as -- -r %r -- %f"
set pgp_encrypt_sign_command="/usr/lib/mutt/pgpewrap gpg --passphrase-fd 0 --batch --quiet --no-verbose --textmode --output - --encrypt --sign %?a?-u %a? --armor --always-trust --encrypt-to $pgp_sign_as -- -r %r -- %f"
set pgp_import_command="gpg --no-verbose --import -v %f"
set pgp_export_command="gpg --no-verbose --export --armor %r"
set pgp_verify_key_command="gpg --no-verbose --batch --fingerprint --check-sigs %r"
set pgp_list_pubring_command="gpg --no-verbose --batch --with-colons --list-keys %r" 
set pgp_list_secring_command="gpg --no-verbose --batch --with-colons --list-secret-keys %r" 
set pgp_autosign=yes
set pgp_replyencrypt=yes
set pgp_timeout=1800
set pgp_good_sign="^gpg: Good signature from"

Given the symptoms, I'd check on pgp_sign_command. But also check that your configuration is consistent regarding whether you are using gpg or gpg2.

Further reading

Related Question