Like many people I use a password-manage to record logins to websites. I previously used a tool called pwsafe, but these days I switched to using pass.
Although I don't like the fact the meta-data is exposed the tool is very useful, and its integration with git
is both simple and reliable.
Reading about the security issue that recently affected cloudflare made me consider rotating some passwords. Using git
I figured I could look at the last update-time of my passwords. Indeed that was pretty simple:
git ls-tree -r --name-only HEAD | while read filename; do
echo "$(git log -1 --format="%ad" -- $filename) $filename"
done
Of course that's not quite enough because we want it sorted, and to do that using the seconds-since-epoch is neater. All together I wrote this:
#!/bin/sh
#
# Show password age - should be useful for rotation - we first of all
# format the timestamp of every *.gpg file, as both unix+relative time,
# then we sort, and finally we output that sorted data - but we skip
# the first field which is the unix-epoch time.
#
( git ls-tree -r --name-only HEAD | grep '\.gpg$' | while read filename; do \
echo "$(git log -1 --format="%at %ar" -- $filename) $filename" ; done ) \
| sort | awk '{for (i=2; i<NF; i++) printf $i " "; print $NF}'
Not the cleanest script I've ever hacked together, but the output is nice:
steve@ssh ~ $ cd ~/Repos/personal/pass/
steve@ssh ~/Repos/personal/pass $ ./password-age | head -n 5
1 year, 10 months ago GPG/[email protected]
1 year, 10 months ago GPG/[email protected]
1 year, 10 months ago GPG/[email protected]
1 year, 10 months ago Git/git.steve.org.uk/root.gpg
1 year, 10 months ago Git/git.steve.org.uk/skx.gpg
Now I need to pick the sites that are more than a year old and rotate credentials. Or delete accounts, as appropriate.
Tags: git, passwords 4 comments
https://www.tomica.me
I've come up with following, "almost oneliner" script after looking at your article:
Reason for using it instead of git is that some folks aren't necessarily using Git integration of password store.