sh/shell/gpg.sh

28 lines
483 B
Bash
Raw Normal View History

2024-11-17 16:28:52 +00:00
# turn gpg agent off
gak() { gpg_agent_kill "${@}"; }
gpg_agent_kill() {
gpgconf \
--kill "gpg-agent"
}
# bind gpg agent to current tty
gau() { gpg_agent_update "${@}"; }
gpg_agent_update() {
gpg-connect-agent \
updatestartuptty \
/bye
}
2024-11-12 05:26:59 +00:00
gpg_ssh() {
local user_id
user_id=$(id --user)
if [ "${user_id}" -ne 0 ]; then
if [ -f "${HOME}/.gnupg/gpg-agent.conf" ]; then
SSH_AUTH_SOCK="$(gpgconf --list-dirs agent-ssh-socket)"
export SSH_AUTH_SOCK
fi
fi
}
gpg_ssh