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 vars=$(keychain --timeout "$lifetime" --eval --host "$keychain_host" $keys)
49 unset SSH_AUTH_SOCK SSH_AGENT_PID
50 vars=$(keychain --timeout "$lifetime" --eval --host "$keychain_host")
53 echo with-agent: Running: "$@"
62 echo "Loading default keys (lifetime $lifetime)..."
63 with-agent ssh-add -t "${lifetime}m" "$@" $keys
66 echo "Loading keys (lifetime $lifetime):" "$@"
67 with-agent ssh-add -t "${lifetime}m" "$@"
76 with-keys "$SHELL" "$@"
79 #with-keys ssh -l root "$@"
83 if [ -z "$command" ]; then
86 echo Executing: "$command" "$@"
87 with-agent "$command" "$@"