sshroot: minor cleanup, feature, and bugfixes
authorAlex Dehnert <adehnert@mit.edu>
Mon, 12 Mar 2012 18:37:13 +0000 (14:37 -0400)
committerAlex Dehnert <adehnert@mit.edu>
Mon, 12 Mar 2012 18:37:13 +0000 (14:37 -0400)
* delete some kerberos-related lines
* don't default to root for ssh'ing
* set an environment variable to indicate running under sshroot
* allowing passing arguments to the shell subcommand
* display the command being run

sshroot

diff --git a/sshroot b/sshroot
index 97ae2ea7ab46ebf6df8b0d01be7f7447de718479..5c41dfab1cdeab2192164883f57693a652b291c5 100755 (executable)
--- a/sshroot
+++ b/sshroot
@@ -1,6 +1,4 @@
 #!/bin/bash
-export KRB5CCNAME=/tmp/krb5cc_$(id -u).root
-export KRBTKFILE=/dev/null
 
 # lifetime, in minutes
 lifetime=15
@@ -14,6 +12,7 @@ function with-keys
 {
     unset SSH_AUTH_SOCK SSH_AGENT_PID
     eval $(keychain --timeout $lifetime --eval --host "$hostopt-root" $keys)
+    export SSHROOT=1
     exec "$@"
 }
 
@@ -21,6 +20,8 @@ function with-agent
 {
     unset SSH_AUTH_SOCK SSH_AGENT_PID
     eval $(keychain --timeout $lifetime --eval --host "$hostopt-root")
+    export SSHROOT=1
+    echo with-agent: Running: "$@"
     exec "$@"
 }
 
@@ -43,10 +44,11 @@ case "$command" in
         with-agent ssh-add -D
         ;;
     shell)
-        with-keys $SHELL
+        with-keys "$SHELL" "$@"
         ;;
     ssh)
-        with-keys ssh -l root "$@"
+        #with-keys ssh -l root "$@"
+        with-keys ssh "$@"
         ;;
     *)
         if [ -z "$command" ]; then