8 [ -z "$hostopt" ] && hostopt="${HOSTNAME}"
9 [ -z "$hostopt" ] && hostopt=`uname -n 2>/dev/null || echo unknown`
11 while getopts "H:k:l:" opt; do
13 H) hostopt="$OPTARG";;
14 k) keysuffix="$OPTARG";;
15 l) lifetime="$OPTARG";;
16 \?) die "$0 [-H hostname] [-k keysuffix] [-l lifetime]"
19 shift $(($OPTIND - 1))
21 keys="$HOME/.ssh/id_rsa_$keysuffix"
22 keychain_host="$hostopt-$keysuffix"
26 unset SSH_AUTH_SOCK SSH_AGENT_PID
27 eval $(keychain --timeout "$lifetime" --eval --host "$keychain_host" $keys)
34 unset SSH_AUTH_SOCK SSH_AGENT_PID
35 eval $(keychain --timeout "$lifetime" --eval --host "$keychain_host")
37 echo with-agent: Running: "$@"
46 echo "Loading default keys (lifetime $lifetime)..."
47 with-agent ssh-add -t "${lifetime}m" "$@" $keys
50 echo "Loading keys (lifetime $lifetime):" "$@"
51 with-agent ssh-add -t "${lifetime}m" "$@"
60 with-keys "$SHELL" "$@"
63 #with-keys ssh -l root "$@"
67 if [ -z "$command" ]; then
68 echo "Usage: $0 init" >&2
71 echo " $0 destroy" >&2
73 echo " $0 ssh [args]" >&2
76 echo Executing: "$command" "$@"
77 with-agent "$command" "$@"