8 [ -z "$hostopt" ] && hostopt="${HOSTNAME}"
9 [ -z "$hostopt" ] && hostopt=`uname -n 2>/dev/null || echo unknown`
13 echo "Usage: $0 [-H hostname] [-k keysuffix] [-l lifetime] command"
15 echo "Available commands:"
24 while getopts ":H:k:l:h" opt; do
26 H) hostopt="$OPTARG";;
27 k) keysuffix="$OPTARG";;
28 l) lifetime="$OPTARG";;
30 \?) usage >&2; exit 1;;
33 shift $(($OPTIND - 1))
35 keys="$HOME/.ssh/id_rsa_$keysuffix"
36 keychain_host="$hostopt-$keysuffix"
40 unset SSH_AUTH_SOCK SSH_AGENT_PID
41 eval $(keychain --timeout "$lifetime" --eval --host "$keychain_host" $keys)
48 unset SSH_AUTH_SOCK SSH_AGENT_PID
49 eval $(keychain --timeout "$lifetime" --eval --host "$keychain_host")
51 echo with-agent: Running: "$@"
60 echo "Loading default keys (lifetime $lifetime)..."
61 with-agent ssh-add -t "${lifetime}m" "$@" $keys
64 echo "Loading keys (lifetime $lifetime):" "$@"
65 with-agent ssh-add -t "${lifetime}m" "$@"
74 with-keys "$SHELL" "$@"
77 #with-keys ssh -l root "$@"
81 if [ -z "$command" ]; then
84 echo Executing: "$command" "$@"
85 with-agent "$command" "$@"