From a75c95de5ce2cfe4ce045795d47dbcdb12ab40e1 Mon Sep 17 00:00:00 2001 From: Tony Duckles Date: Sat, 21 Feb 2015 19:35:17 -0600 Subject: [PATCH] .bash_profile: Don't run keychain when sudo'ing Don't re-run keychain when starting a sudo'd shell. When using Fabric + sudo, this was re-running keychain and borked the pre-existing ssh-agent job. Use presence of $SUDO_USER to identify sudo context and prevent re-running keychain. --- .bash_profile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.bash_profile b/.bash_profile index a4e1782..aa883ac 100644 --- a/.bash_profile +++ b/.bash_profile @@ -12,7 +12,8 @@ fi # keychain keychain=$(type -P keychain) -test -n "$keychain" && { +test -n "$keychain" && \ + test -z "$SUDO_USER" && { if [ -f ~/.ssh/id_rsa ]; then eval `$keychain -q ~/.ssh/id_rsa` source ~/.keychain/`hostname`-sh > /dev/null -- 2.47.1