Better sshroot script
authorAlex Dehnert <adehnert@mit.edu>
Fri, 25 Jun 2010 07:48:12 +0000 (03:48 -0400)
committerAlex Dehnert <adehnert@mit.edu>
Fri, 25 Jun 2010 07:48:12 +0000 (03:48 -0400)
Makefile
sshroot

index 60ecdcb85c93db78dbfeacbacc7de889fb1ea734..1aab0b7752a97e361030168c59843848cc217e88 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,6 @@
 archdir=/mit/$(ATHENA_USER)/arch/
 common=$(archdir)/common/
-scripts=bores-me  card-access  grep-owners  ldapfinger list-members  list-of-lists-updater  lists-lint  rt-set  rt-resolve check-host  update-officers make-zcrypt-key get-emails  mail-merge
+scripts=bores-me  card-access  grep-owners  ldapfinger list-members  list-of-lists-updater  lists-lint  rt-set  rt-resolve check-host  update-officers make-zcrypt-key get-emails  mail-merge  sshroot
 arches=i386_deb31  i386_deb40  i386_deb50  i386_rhel4
 
 all : install
diff --git a/sshroot b/sshroot
index 75b1f9861a15d7e621302333c47ded6f4d18987c..bac553444711b88ae85fc6c8b4e9722230c260cf 100755 (executable)
--- a/sshroot
+++ b/sshroot
@@ -15,35 +15,42 @@ function with-keys
     exec "$@"
 }
 
-case $1 in
+command="$1"
+shift
+
+case "$command" in
     init)
-        shift;
-        unset SSH_AUTH_SOCK SSH_AGENT_PID
-        echo exec keychain --host "$hostopt-root" $keys
+        echo "Loading default keys (lifetime $lifetime)..."
+        with-keys ssh-add -t $lifetime "$@" $keys
         ;;
     add)
+        echo "Loading keys (lifetime $lifetime):" "$@"
         with-keys ssh-add -t $lifetime "$@"
         ;;
+    list)
+        with-keys ssh-add -l
+        ;;
     destroy)
         with-keys ssh-add -D
         ;;
     shell)
-        HOSTNAME="`hostname` (sshroot)" with-keys $SHELL
+        with-keys $SHELL
         ;;
     ssh)
-        shift
         with-keys ssh -l root "$@"
         ;;
     *)
-        if [ $# = 0 ]; then
+        if [ -z "$command" ]; then
             echo "Usage: $0 init" >&2
             echo "       $0 add" >&2
+            echo "       $0 list" >&2
             echo "       $0 destroy" >&2
             echo "       $0 shell" >&2
             echo "       $0 ssh [args]" >&2
             echo "       $0 [cmd]" >&2
         else
-            with-keys "$@"
+            echo Executing: "$command" "$@"
+            with-keys "$command" "$@"
         fi
         ;;
 esac