Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I am new to mutt.

I've read this question and implemented it ( 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.

share|improve this question
    
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 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

1 Answer 1

up vote 5 down vote accepted

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
my_password<Ctrl+D>

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.

share|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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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