I have a particular scenario where I make use of different keyrings, personal (default) and professional (secondary) use.
Seems like there is no setting to allow git-secret to look for a different outer keyring.
gpg --no-default-keyring --keyring secondary.gpg --full-generate-key
...
gpg --no-default-keyring --keyring secondary.gpg --armor --export [email protected]
$ git secret whoknows
[email protected]
[email protected]
$ git secret list
hidden.txt
$ git secret cat hidden.txt
gpg: decryption failed: No secret key
git-secret: abort: problem decrypting file with gpg: exit code 2: /home/example/git-secret-test/hidden.txt
The command fails as is unable decrypt the file by using the private key in the secondary keyring.
Been able to decrypt the file
(If it’s long, please paste to https://ghostbin.com/ and insert the link here.)
I was able to workaround it by using a wrapper to gpg as there is a way to override the command with:
SECRETS_GPG_COMMAND=~/.local/bin/gpg-wrap
The wrapper script is:
#!/bin/bash
# When --homedir is passed, it is to override the system default (~/.gnupg)
# And to use the inner one located in ${SECRETS_DIR} (default: ./.gitsecret/keys/)
if grep -q -- '--homedir'<<<"$@"; then
/usr/bin/gpg "$@"
else
/usr/bin/gpg --no-default-keyring --keyring secondary.gpg "$@"
fi
Operating system: (uname -a) …
Linux example 5.4.13-201.fc31.x86_64 #1 SMP Tue Jan 21 17:21:47 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
git-secret path: (which git-secret) …
/usr/bin/git-secret
git-secret version: (git secret --version) …
0.2.6
git version: (git --version) …
2.24.1
Shell type and version: ($SHELL --version) …
GNU bash, version 5.0.11
gpg version: (gpg --version) …
2.2.18
Interesting feature! Thanks, @tonyskapunk!
I think the right solution here is to allow for a SECRETS_GPG_KEYRING variable (edit: or maybe SECRETS_GPG_USER_KEYRING to make it clear that it won't change the name of the keyring used in the repo's $SECRETS_DIR), that when used causes git-secret to use the -no-default-keyring --keyring $SECRETS_GPG_KEYRING gnupg options when handling the user's keyring.
What do you thnk, @sobolevn and @tonyskapunk ?
Seems like a good idea!
Hm this sort of interacts with git-secret-tell / hide / init / killperson's -d option, i have to think this through:
From man git-secret-tell:
-d - specifies `--homedir` option for the `gpg`,
basically use this option if your store your keys in a custom location.
Input welcome
Sorry for the lack of response here, I appreciate you're taking a look to this and have suggestions already. :smile_cat:
I like the idea of SECRETS_GPG_USER_KEYRING.
Regarding -d in secret tell it will only allow to use a different outer directory, still defaulting to the default keyring. Although this is a good alternative for sure. I'd think I could use a different directory instead of a secondary keyring. Lemme try and I'll update how it goes.
Thanks again!
Most helpful comment
Sorry for the lack of response here, I appreciate you're taking a look to this and have suggestions already. :smile_cat:
I like the idea of
SECRETS_GPG_USER_KEYRING.Regarding
-dinsecret tellit will only allow to use a different outer directory, still defaulting to the default keyring. Although this is a good alternative for sure. I'd think I could use a different directory instead of a secondary keyring. Lemme try and I'll update how it goes.Thanks again!