summaryrefslogtreecommitdiffstats
path: root/.bash_profile
diff options
context:
space:
mode:
Diffstat (limited to '.bash_profile')
-rw-r--r--.bash_profile7
1 files changed, 5 insertions, 2 deletions
diff --git a/.bash_profile b/.bash_profile
index 55c8ca3..8983cb0 100644
--- a/.bash_profile
+++ b/.bash_profile
@@ -39,8 +39,11 @@ export LANG=en_US.UTF-8
GPG_TTY=$(tty)
export GPG_TTY
unset SSH_AGENT_PID
-# If SSH_AUTH_SOCK is empty, then set it, otherwise it's already set by ForwardAgent
-if [ -z "$SSH_AUTH_SOCK" ]; then
+
+# macOS locally: SSH_AUTH_SOCK is empty (FALSE) || SSH_CONNECTION is empty (TRUE) = uses gpg-agent
+# Linux locally: SSH_AUTH_SOCK might be empty (TRUE) || SSH_CONNECTION is empty (TRUE) = uses gpg-agent
+# SSH session: SSH_AUTH_SOCK is empty (FALSE) || SSH_CONNECTION is empty (FALSE) = keep forwarded agent
+if [ -z "$SSH_AUTH_SOCK" ] || [ -z "$SSH_CONNECTION" ]; then
SSH_AUTH_SOCK=$(gpgconf --list-dirs agent-ssh-socket)
export SSH_AUTH_SOCK
fi