1

first try: (with --no-tty in my msmtp config)

  • (reboot)
  • head -n 1 ~/.gnupg/gpg.conf

    use-agent

  • gpg agent is started:

    % systemctl --user status gpg-agent.service
    gpg-agent.service - GnuPG private key agent
    Loaded: loaded (/home/toogley/.dotfiles/systemd/user/gpg-agent.service; enabled)
    Active: active (running) since Wed 2015-12-30 17:42:31 CET; 23s ago Process: 1290 ExecStart=/usr/bin/gpg-agent --daemon --homedir=%h/.gnupg (code=exited, status=0/SUCCESS)
    Main PID: 1295 (gpg-agent)
    CGroup: /user.slice/user-1000.slice/user@1000.service/gpg-agent.service └─1295 /usr/bin/gpg-agent --daemon --homedir=/home/toogley

/.gnupg

  • Password with in devMailPW.asc: gpg -e -a -r $(my email adress)
  • it doesn't change anything, if i put a \n after the PW, as suggested here: https://wiki.archlinux.org/index.php/GPG#Encrypt_and_decrypt
  • gpg -d devMail.asc ==> spawns dialog to enter PW for the first time
  • afterwards gpg -d devMail.asc doesn't require me to enter my PW
  • sending a mail with mutt results in:

    gpg: gpg-agent is not available in this session gpg: Sorry, no terminal at all requested - can't get input msmtp: cannot read output of 'gpg -d --no-tty /home/toogley/.dotfiles/mutt/accounts/devMailPW.asc'

  • the relevant part in my muttrc:

    set sendmail="msmtp --file=/home/toogley/.dotfiles/mutt/accounts/dev.smtp"

  • my dev.smtp:

    passwordeval "gpg -d --no-tty /home/toogley/.dotfiles/mutt/accounts/devMailPW.asc"

second try: (without --no-tty in my msmtp config)

  • (same as before)
  • sending a mail with mutt results in:

    gpg: cannot open tty `/dev/tty': No such device or address msmtp: cannot read output of 'gpg -d +/home/toogley/.dotfiles/mutt/accounts/devMailPW.asc'

third try: (with --batch)

  • (same as before)
  • (% gpg -d --batch devMailPW.asc works properly)
  • sending a mail with mutt results in:

    gpg: gpg-agent is not available in this session
    gpg: can't query passphrase in batch mode
    gpg: Invalid passphrase; please try again ...
    gpg: can't query passphrase in batch mode
    gpg: Invalid passphrase; please try again ...
    gpg: can't query passphrase in batch mode
    gpg: encrypted with 2048-bit RSA key, ID 3970B3E5, created 2015-12-28
    ""
    gpg: public key decryption failed: bad passphrase
    gpg: decryption failed: secret key not available
    msmtp: cannot read output of 'gpg -d --batch
    +/home/toogley/.dotfiles/mutt/accounts/devMailPW.asc'

EDIT tmux plays an essential role in that situation.

=> the first and third approach works outside of my tmux environment. it spawns even for my password and asks for it. (which is great)

  • Do you start tmux before or after you start the gpg agent? – John Dec 30 '15 at 18:31
  • The tests were made with starting the tmux session after the gpg agent – toogley Dec 30 '15 at 18:38
  • What happens if you start the GPG agent inside the tmux session? It may be that the new shell inside tmux can't talk tot he agent running outside that shell. – John Dec 30 '15 at 19:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.