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

#set imap_pass = ""
#set smtp_pass = ""

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


Comments

6 responses to “MUTT – encrypting password with GNUpg”

  1. Satnam..!! Avatar
    Satnam..!!

    great w0rk…man..!!
    UNIQUE….

  2. […] passwordeval variable tells the msmtp to fetch password from an encryped gpg file. More details on Encrypting password in with GnuPG, of course you need to see what you want from that […]

  3. soko1 Avatar
    soko1

    Hi!

    DELETE CODE:

    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`

    ADD:

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

  4. Vigas Deep Avatar
    Vigas Deep

    Updated, thanks for the input.

  5. […] like leaving then in plain text in a file on my hard drive. I could encrypt them (as described here https://www.vigasdeep.com/mutt-encrypting-password-with-gnupg/) but then I would need to type a passphrase in to decrypt the password which kind of defeats the […]

  6. […] like leaving then in plain text in a file on my hard drive. I could encrypt them (as described here https://www.vigasdeep.com/mutt-encrypting-password-with-gnupg/) but then I would need to type a passphrase in to decrypt the password which kind of defeats the […]

Leave a Reply

%d bloggers like this: