sshroot: store the timeout in minutes
[user/alex/software/my-snippets.git] / sshroot
diff --git a/sshroot b/sshroot
index 6a0c4b5f6e8d906e1d572c75e54a7e3a2b78adf5..97ae2ea7ab46ebf6df8b0d01be7f7447de718479 100755 (executable)
--- a/sshroot
+++ b/sshroot
@@ -2,7 +2,9 @@
 export KRB5CCNAME=/tmp/krb5cc_$(id -u).root
 export KRBTKFILE=/dev/null
 
-lifetime=900
+# lifetime, in minutes
+lifetime=15
+
 hostopt=""
 [ -z "$hostopt" ] && hostopt="${HOSTNAME}"
 [ -z "$hostopt" ] && hostopt=`uname -n 2>/dev/null || echo unknown`
@@ -11,14 +13,14 @@ keys=~/.ssh/id_rsa_root
 function with-keys
 {
     unset SSH_AUTH_SOCK SSH_AGENT_PID
-    eval $(keychain --eval --host "$hostopt-root" $keys)
+    eval $(keychain --timeout $lifetime --eval --host "$hostopt-root" $keys)
     exec "$@"
 }
 
 function with-agent
 {
     unset SSH_AUTH_SOCK SSH_AGENT_PID
-    eval $(keychain --eval --host "$hostopt-root")
+    eval $(keychain --timeout $lifetime --eval --host "$hostopt-root")
     exec "$@"
 }
 
@@ -28,11 +30,11 @@ shift
 case "$command" in
     init)
         echo "Loading default keys (lifetime $lifetime)..."
-        with-agent ssh-add -t $lifetime "$@" $keys
+        with-agent ssh-add -t ${lifetime}m "$@" $keys
         ;;
     add)
         echo "Loading keys (lifetime $lifetime):" "$@"
-        with-agent ssh-add -t $lifetime "$@"
+        with-agent ssh-add -t ${lifetime}m "$@"
         ;;
     list)
         with-agent ssh-add -l