* Rename with-keys to with-agent to better reflect what it does
* Make a new with-keys that does the same thing as with-agent, except
that it passes $keys to keychain so that those keys are actually
unlocked
* Divide between using with-keys and with-agent more-or-less
reasonably
keys=~/.ssh/id_rsa_root
function with-keys
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")
{
unset SSH_AUTH_SOCK SSH_AGENT_PID
eval $(keychain --eval --host "$hostopt-root")
case "$command" in
init)
echo "Loading default keys (lifetime $lifetime)..."
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):" "$@"
;;
add)
echo "Loading keys (lifetime $lifetime):" "$@"
- with-keys ssh-add -t $lifetime "$@"
+ with-agent ssh-add -t $lifetime "$@"
;;
shell)
with-keys $SHELL
;;
shell)
with-keys $SHELL
echo " $0 [cmd]" >&2
else
echo Executing: "$command" "$@"
echo " $0 [cmd]" >&2
else
echo Executing: "$command" "$@"
- with-keys "$command" "$@"
+ with-agent "$command" "$@"