From 763d199cdef29cc40b9ba30b5a032209dcb9f41e Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 12 Nov 2024 06:26:59 +0100 Subject: [PATCH] gpg_ssh --- bash/gpg.sh | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/bash/gpg.sh b/bash/gpg.sh index 358b4ca..f9d6ef6 100644 --- a/bash/gpg.sh +++ b/bash/gpg.sh @@ -1,5 +1,12 @@ -if [ ${EUID} -ne 0 ] ; then - if [ -f "${HOME}/.gnupg/gpg-agent.conf" ] ; then - export SSH_AUTH_SOCK="$(gpgconf --list-dirs agent-ssh-socket)" - fi -fi +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