From 5f21ee10871fa9ef672c9aedfe8aee3d5e4ee73e Mon Sep 17 00:00:00 2001 From: Alex Dehnert Date: Fri, 25 Jun 2010 03:48:12 -0400 Subject: [PATCH] Better sshroot script --- Makefile | 2 +- sshroot | 23 +++++++++++++++-------- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/Makefile b/Makefile index 60ecdcb..1aab0b7 100644 --- 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 75b1f98..bac5534 100755 --- 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 -- 2.34.1