Search code examples
gnupgmutt

Use gpg password from pass as variable in a script


I try to create an autologin to use posteo within neomutt.

Is it possible to use the gpg file from the pass folder

.password-store/

in a .muttrc config?

In the Mutt Archwiki there is the following Password-Manger section:

1.create file and input

set my_pass = "password"

2.encrypt the file and call the gpg in muttrc

source "gpg -dq $HOME/.my-pwds.gpg |"

3.call password in a script

set imap_pass=$my_pass

This should work, but i want to use my existing pass gpg file directly. I have the passport gpg file decrypted for testing, but the file only contains the password without an addition. How to use this password as a variable in my script?


Solution

  • I've found a solution for my problem

    1.Copy gpg.rc from samples

    cp /usr/share/doc/neomutt/samples/gpg.rc ~/.mutt
    

    My .neomuttrc use a source file like this:

    source ~/.mutt/gpg.rc                               
    
    set my_pass=`pass Email/...`   
    
    # Receive options                                 
    set from="[email protected]"                     
    set hostname="posteo.de"                                     
    set realname='urename'                           
    set imap_login='[email protected]'               
    set imap_pass=$my_pass                                 
    set folder="imaps://[email protected]@posteo.de/"
    set spoolfile="=INBOX"                                 
    set record="=Sent"                            
    set postponed="=Drafts"                       
    
    # Send options                                                                      
    smtp_url="                                                                
    set from="[email protected]"                                            
    
    # Hook                                                                        
    account-hook $folder "set [email protected] imap_pass=$my_pass"