MUTT – encrypting password with GNUpg

To encrypt password with mutt, we will be using GNUpg, install it :

For Debian based : $ sudo apt-get install gnupg gnupg-agent
For RPM based : $ sudo yum install gnupg gnupg-agent

after installing it you need to generate an encryption key by using following.

gpg --gen-key

Select appropriate options. Enter you name, email and passphare when it asks. Do not forget your passphrase.
now create a file .pass place it in your home folder, I am placing it here :

touch ~/.mutt/.pass

contents fo following file should be :

GMail:<use tab>mySecretPassowrd

encrypt it by using:

cd ~/.mutt
gpg --encrypt .pass

Now you will see a file is created as .pass.gpg , if it is there, you can delete orignal .pass file. After this step you have to make changes to .muttrc file. Append the following by doing appropriate changes

set imap_pass = `gpg -d ~/.mutt/.pass.gpg | awk '/GMail:/ {print $2}'`

NOTE : if imap_pass and smtp_pass are defined anywhere else, you have to remove them or comment those two lines like this :

#<s>set imap_pass = ""</s>
#<s>set smtp_pass = ""</s>

Thats it, now you can start mutt and it will ask the passphrase for your key, and will never irritate you again 🙂
Good Luck.

6 thoughts on “MUTT – encrypting password with GNUpg

  1. Hi!


    set my_tmp=`gpg -o ~/.mutt/.tmp -d ~/.mutt/.pass.gpg`
    # decrypted password
    set my_gpass=`awk ‘/GMail:/ {print $2}’ ~/.mutt/.tmp`
    # setting passwords
    set imap_pass = $my_gpass
    set smtp_pass = $my_gpass
    # Deleting .tmp file immidiately
    set my_del=`rm -f ~/.mutt/.tmp`


    set imap_pass = `gpg -d ~/.mutt/.pass.gpg | awk ‘/GMail:/ {print $2}’`

Leave a Reply