diff --git a/bin/startagent b/bin/startagent index cbf77b4..c1d7e99 100755 --- a/bin/startagent +++ b/bin/startagent @@ -35,6 +35,7 @@ usage(){ Just to be asked for password again, if you plugged off hardware-token and plugged it in again. --rm|--remove remove keys and token instead of adding them. + -R|--restart-agent -h|--info Show this info @@ -103,7 +104,9 @@ set_and_load_identity_config() { if [ -e "${ssh_identity_dir}/config" ]; then logdebug "source ${ssh_identity_dir}/config" unset SSH_AUTH_SOCK SSH_AGENT_PID PKCS11_MODULE SSH_AGENT_ALLOW_FROM_REMOTE SSH_ADD_OPTION + set -a . "${ssh_identity_dir}/config" + set +a fi } @@ -116,6 +119,8 @@ start_or_restart_local_agent() { logdebug "SSH_AUTH_SOCK: ${SSH_AUTH_SOCK:-not set}" logdebug "SSH_AGENT_PID: ${SSH_AGENT_PID:-not set}" logdebug "PKCS11_MODULE: ${PKCS11_MODULE:-not set}" + # kill ssh-agent when wanted from options + ${restartagent:-false} && ssh-agent -k for i in $(pgrep -f ${SSH_AUTH_SOCK}) do logdebug "$(stat ${SSH_AUTH_SOCK})" @@ -348,6 +353,10 @@ keyonly=false remove=false while :; do case $1 in + -r|--restart-agent) + restartagent=true + shift + ;; -c|--create-only) createonly=true shift @@ -394,6 +403,7 @@ fi logdebug " PKCS11_MODULE=${PKCS11_MODULE:-not set}" logdebug " SSH_ADD_OPTIONS=${SSH_ADD_OPTIONS:-not set}" +logdebug " SSH_AGENT_OPTIONS=${SSH_AGENT_OPTIONS:-not set}" logdebug "SSH_AGENT_ALLOW_FROM_REMOTE=${SSH_AGENT_ALLOW_FROM_REMOTE:-false}" logdebug " PKCS11_MODULE=${PKCS11_MODULE:-not set}" logdebug " P11M=${P11M:-not set}"