keys=~/.ssh/id_rsa_root
function with-keys
+{
+ unset SSH_AUTH_SOCK SSH_AGENT_PID
+ eval $(keychain --eval --host "$hostopt-root" $keys)
+ exec "$@"
+}
+
+function with-agent
{
unset SSH_AUTH_SOCK SSH_AGENT_PID
eval $(keychain --eval --host "$hostopt-root")
case "$command" in
init)
echo "Loading default keys (lifetime $lifetime)..."
- with-keys ssh-add -t $lifetime "$@" $keys
+ with-agent ssh-add -t $lifetime "$@" $keys
;;
add)
echo "Loading keys (lifetime $lifetime):" "$@"
- with-keys ssh-add -t $lifetime "$@"
+ with-agent ssh-add -t $lifetime "$@"
;;
list)
- with-keys ssh-add -l
+ with-agent ssh-add -l
;;
destroy)
- with-keys ssh-add -D
+ with-agent ssh-add -D
;;
shell)
with-keys $SHELL
echo " $0 [cmd]" >&2
else
echo Executing: "$command" "$@"
- with-keys "$command" "$@"
+ with-agent "$command" "$@"
fi
;;
esac