From 12591e94b0ac40484fc0d6fa6917084906432f9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakobus=20Sch=C3=BCrz?= Date: Sun, 20 Sep 2020 20:23:12 +0200 Subject: [PATCH] improve token-handling --- functions.sh | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/functions.sh b/functions.sh index 8adcd86..1e4c68d 100755 --- a/functions.sh +++ b/functions.sh @@ -836,7 +836,7 @@ token-list-objects() { } -loadagent () { +ssh-loadagent () { # TODO: create agent if not running cat << EOF @@ -844,15 +844,27 @@ loadagent () { SSH_AGENT_PID: ${SSH_AGENT_PID} --------------------------------------------- EOF - ssh_identity=$1 + ssh_identity=${1-default} + agentfile="${HOME}/.ssh/agents/agent-${ssh_identity}-$(hostname)" + echo agentfile: $agentfile if [ -n "${ssh_identity+x}" ]; then - agentfile="${HOME}/.ssh/agents/agent-${ssh_identity}-$(hostname)" if [ -e "$agentfile" ]; then . $agentfile + if ssh-add -l >/dev/null ;then + echo agent is running + else + echo create new agent + ssh-agent > "$agentfile" + fi + else + echo create new agent + ssh-agent > "$agentfile" fi fi + eval $(<$agentfile) + cat << EOF SSH_AUTH_SOCK: ${SSH_AUTH_SOCK} SSH_AGENT_PID: ${SSH_AGENT_PID}