Remove keychain for gpg-agent

This commit is contained in:
gardouille 2021-09-19 23:21:52 +02:00
parent 8841520957
commit d3a5ff8349
Signed by: gardouille
GPG Key ID: E759BAA22501AF32
3 changed files with 20 additions and 21 deletions

12
zlogin
View File

@ -77,16 +77,6 @@ if [ ${USER} != "root" ] && [ $(command -v startx) ]; then
fi
fi
# ssh-agent with fix socket path {{{
# ssh-agent with fix socket path
## See load-ssh-agent function in ~/.zsh/zshrc
load-ssh-agent
# }}}
# GPG Agent {{{
if [ -f $HOME/.gnupg/secring.gpg ]; then
# Keychain
## Don't ask for gpg password, it will be asked at the first usage
keychain --noask --agents gpg
. $HOME/.keychain/$HOST-sh-gpg
fi
# }}}

4
zshenv
View File

@ -108,3 +108,7 @@ SSH_AGENT_ENV="${HOME}/.ssh/socks/ssh_agent_env"
## ssh-keys path
SSH_ED25519_KEY="${HOME}/.ssh/id_ed25519"
SSH_RSA_KEY="${HOME}/.ssh/id_rsa"
# GPG
GPG_PRIV_KEY="${HOME}/.gnupg/secring.gpg"
GPG_TEST_FILE="${HOME}/.password-store/test"

25
zshrc
View File

@ -373,19 +373,24 @@ alias scpdev='scp -o UserKnownHostsFile=/dev/null'
# }}}
## Keychain for GPG {{{
function gpg() {
## If keychain exists, run gpg from default $PATH as usual
if [ -f ~/.keychain/"${HOST}"-sh-gpg ]; then
command -p gpg ${*}
else ## Otherwise, reload keychain and run gpg
keychain --agents gpg
source ~/.keychain/"${HOST}"-sh-gpg
command -p gpg ${*}
# GPG {{{
#########
# Load gpg-agent {{{
## This function can be used :
## 1. with aliases (git commit,…)
function load-gpg-agent() {
## If a gpg key is available
if [ -f "${GPG_PRIV_KEY}" ]; then
## Remove any previous test file
rm --force -- "${GPG_TEST_FILE}"
## Run a gpg command on the test file
gpg --quiet --for-your-eyes-only --decrypt "${GPG_TEST_FILE}.gpg" > /dev/null
fi
}
## }}}
# }}}
# }}}
# Taskwarrior {{{
## Aliases