From 00845cf796d8e9553c2f32bf87462147fda7eb00 Mon Sep 17 00:00:00 2001 From: Mark Lee Date: Thu, 17 Jan 2019 13:52:02 -0500 Subject: [PATCH] Fix ssh-agent check to use $SSH_AGENT_PID and $SSH_AUTH_SOCK instead of counting the number of ssh-agent instances --- util.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/util.sh b/util.sh index 0ccd6af..1c917f9 100644 --- a/util.sh +++ b/util.sh @@ -228,9 +228,10 @@ function store_pemkey { chmod 400 ~/.ssh/${unique_pemkeys}.pem cp ~/.ssh/${unique_pemkeys}.pem ${PEG_ROOT}/tmp/${cluster_name} - - sshagent_pid_cnt=$(pgrep ssh-agent | wc -l) - if [ "${sshagent_pid_cnt}" -ne "0" ]; then + if [ $SSH_AGENT_PID ]; then + if ! [ $SSH_AUTH_SOCK ]; then + eval $(ssh-agent -s) + fi ssh-add ${PEG_ROOT}/tmp/${cluster_name}/${unique_pemkeys}.pem > /dev/null 2>&1 echo "${unique_pemkeys}.pem has been added to your ssh-agent" else