pyratelog

personal blog
git clone git://git.pyratebeard.net/pyratelog.git
Log | Files | Refs | README

20220419-passtardly_and_muttley.md (1751B)


      1 I am a command line enthusiast so a lot of the utilities I use are terminal based, including my password manager of choice, [pass](https://www.passwordstore.org/){target="_blank" rel="noreferrer"}.
      2 
      3 My email client of choice is also terminal based, [mutt](http://www.mutt.org/){target="_blank" rel="noreferrer"}.  I track the muttrc config file as part of my [dotfiles](https://gitlab.com/pyratebeard/dotfiles){target="_blank" rel="noreferrer"} repo and obviously I don't want to keep passwords in this file.
      4 
      5 For a long time I would have the password in the file on my local system and had to remember to be careful when adding and committing changes to my repo.  All that remembering was exhausting.
      6 
      7 About a year ago I finally started using [offlineimap](https://github.com/OfflineIMAP/offlineimap){target="_blank" rel="noreferrer"} to sync my mail to my local system.  While setting up my offlineimaprc config I found that it is possible to import passwords using python.  I created a simple python file
      8 ```
      9 #!/usr/bin/env python
     10 from subprocess import check_output
     11 
     12 def get_pass(account):
     13     return check_output("pass email/" + account + "/passwd", shell=True).splitlines()[0]
     14 ```
     15 
     16 then imported the file in the `[general]` section of offlineimaprc, and imported the password using `remotepasseval` in the repository section
     17 ```
     18 [general]
     19 pythonfile = ~/.offlineimap.py
     20 
     21 [Repository remote]
     22 remotepasseval = get_pass("pyratebeard")
     23 ```
     24 
     25 I use the `account` argument as I have multiple accounts with different passwords.
     26 
     27 While setting this up I also discovered that commands can be used in muttrc to import paswords
     28 
     29 ```
     30 set my_pass = "`pass email/pyratebeard/passwd`"
     31 
     32 set smtp_pass = $my_pass
     33 ```
     34 
     35 Now I can forget about all that remembering.