I am new to mutt.

I've read this question and implemented it ( https://superuser.com/questions/31305/mutt-how-to-safely-store-password ) but it's not the ideal solution I'm after.

Really, I want mutt to prompt me once at the beginning of a session for my imap password, and store it in memory as both my imap and smtp password. I'm not sure if this is possible.

The hack above works, but feels a little kludgy and means having my password written out to disk, even if it is encrypted, I'm a paranoid person.

  • What do you have against leaving imap_pass unset, as mentioned in the accepted answer to the question you link? This matches both your security requirements and your user experience requirements. – Gilles 'SO- stop being evil' Dec 16 '10 at 22:18
  • If I leave it unset, then it prompts me for the password when I start mutt to retrieve my mail, and then prompts me again to send it. If I mistype when sending, it hangs mutt and refuses to work. I would rather have my mutt session be fully authenticated until I close it. – richo Dec 16 '10 at 22:49

Personally, I use GnuPG in order to store my passwords.

The passwords are stored in encrypted files. Whenever I start mutt, it tries to decrypt the passwords and GnuPG automatically asks me for the password to my private key. The passwords are then remembered by mutt for the current session and forgotten afterwards.

Mutt configuration looks like this:

set my_pw1=`gpg --batch -q --decrypt ~/.mutt/acc1pw`
set my_pw2=`gpg --batch -q --decrypt ~/.mutt/acc2pw`

set imap_pass=$my_pw1
set smtp_pass=$my_pw2

The first two lines will load the encrypted passwords, and the last two lines will set them as the IMAP and SMTP passwords respectively. You can also just use one password instead of two, the reason I use different passwords is because I have multiple accounts that are not on the same server.

In order to store your passwords in encrypted files, you have to make sure you store only your passwords, without any additional characters (that includes newlines). You can do it from the command line like this:

$ gpg --encrypt -r RECIPIENT > ~/.mutt/acc1pw

That should work the way you except it to. You'll need a GnuPG public/private keypair for this to work the way I posted it above. As far as I know GnuPG can also do symmetric encryption but I never tried that, so your mileage may vary. The manpage should be able to help you with the that though.

| improve this answer | |
  • Isn't echoing the password a very bad idea? It'll be stored in your bash history! – Hendrik Vogt Mar 13 '13 at 13:07
  • Yeah, that's a good point - removed the offending line. Thanks :-) – Cedric Mar 13 '13 at 13:44
  • I would recommend passwordstore.org used in the same way as in the @Cedric's answer. So it would be like set my_pw1=`pass acc1` – Jakub Jindra Apr 9 '19 at 6:59

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.