diff options
author | Sam Chudnick <sam@chudnick.com> | 2022-01-05 18:01:25 -0500 |
---|---|---|
committer | Sam Chudnick <sam@chudnick.com> | 2022-01-05 18:01:25 -0500 |
commit | a7ec0d3b3e49837c52051de489b118b650bb2bf0 (patch) | |
tree | c3a3aae5ed27c1209beae4028987f99661cdb8fc | |
parent | 2332407c0da4307b608061c9b20bd5dcef4c5cd7 (diff) |
Prompt for KeePassXC password until correct one is given.
-rwxr-xr-x | .local/bin/id-init | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/.local/bin/id-init b/.local/bin/id-init index d51660a..11221c3 100755 --- a/.local/bin/id-init +++ b/.local/bin/id-init | |||
@@ -12,9 +12,17 @@ | |||
12 | # gpg-preset-passphrase respects gpg-agent's --max-cache-ttl option which defaults to 2 hours | 12 | # gpg-preset-passphrase respects gpg-agent's --max-cache-ttl option which defaults to 2 hours |
13 | # you may want to increase that if you want the password to be cached for the whole session | 13 | # you may want to increase that if you want the password to be cached for the whole session |
14 | 14 | ||
15 | get_pass() { | ||
16 | continue=1 | ||
17 | while [ $continue -eq 1 ] | ||
18 | do | ||
19 | keepassxc-cli show $XDG_CONFIG_HOME/keepassxc/Passwords.kdbx -a Password GPG | ||
20 | continue=$? | ||
21 | done | ||
22 | } | ||
23 | |||
15 | KEYGRIP="$(gpg -K --with-keygrip --with-colons | grep grp | tail -n 1 | cut -d':' -f10)" | 24 | KEYGRIP="$(gpg -K --with-keygrip --with-colons | grep grp | tail -n 1 | cut -d':' -f10)" |
16 | /usr/lib/gnupg/gpg-preset-passphrase --preset $KEYGRIP \ | 25 | /usr/lib/gnupg/gpg-preset-passphrase --preset $KEYGRIP <<< "$(get_pass)" |
17 | <<< "$(keepassxc-cli show $XDG_CONFIG_HOME/keepassxc/Passwords.kdbx -a Password GPG)" | ||
18 | 26 | ||
19 | # Open graphical KeePassXC with password stored in pass, now that pass can be accessed | 27 | # Open graphical KeePassXC with password stored in pass, now that pass can be accessed |
20 | # without entering credentials for the GPG key | 28 | # without entering credentials for the GPG key |