diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2021-08-17 10:49:49 +0200 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2021-08-17 10:49:49 +0200 |
commit | e3d5a59dcab323b40b836ce4f965080eca407319 (patch) | |
tree | a6917ad7fd34e248371c13d805ddd282f11ca77a /bashrc | |
parent | ce485ee9e4f85d65d9c4b35ef7fead3fe7dc4763 (diff) | |
download | bin-e3d5a59dcab323b40b836ce4f965080eca407319.zip bin-e3d5a59dcab323b40b836ce4f965080eca407319.tar.gz |
bashrc : cleaner ssh-agent script
Diffstat (limited to 'bashrc')
-rw-r--r-- | bashrc | 30 |
1 files changed, 9 insertions, 21 deletions
@@ -134,26 +134,14 @@ function xtract() { } # SSH -SSH_ENV=${HOME}/.ssh/environment -function start_agent { - /usr/bin/ssh-agent | sed 's/^echo/#echo/' > ${SSH_ENV} - chmod 600 ${SSH_ENV} - . ${SSH_ENV} > /dev/null - # /usr/bin/ssh-add $(ls ~/.ssh/*.pub | sed 's/\.pub.*//g' | tr '\n' ' ') -} -if [ -e "${SSH_ENV}" ] +ssh-add -l &>/dev/null +if [ $? -ne 0 ] then - . ${SSH_ENV} > /dev/null - ps ux | grep ssh-agent$ | grep ${SSH_AGENT_PID} >/dev/null || { - # kill old agents - PIDS=`pidof ssh-agent` - if [ ! -z "${PIDS}" ]; then - for PID in ${PIDS}; do - kill ${PID} 2>/dev/null - done - fi - start_agent; - } -else - start_agent + [ -r ~/.ssh/agent ] && eval "$(<~/.ssh/agent)" >/dev/null + ssh-add -l &>/dev/null + if [ $? -ne 0 ] + then + (umask 066; ssh-agent > ~/.ssh/agent) + eval "$(<~/.ssh/agent)" >/dev/null + fi fi |