#!/bin/sh # For # put this in /usr/local/bin/sudo_ssh_workarounds # along with a sudo_ssh_username script to use a non-root user's ssh keys # If DISPLAY is not set, try to find a display where we are logged in. # This should usually be :0.0 if [ ! -n "$DISPLAY" ]; then ME=`whoami` SESSION=`who | grep $ME | grep '(:' | head -n 1` POS=`expr index "$SESSION" '\('` export DISPLAY=`expr substr "${SESSION}" $POS 10 | tr -d '()'` fi # If you already know the location of your program for # graphical password dialogs for ssh set it here and we # won't have to look around for it each time. #export SSH_ASKPASS=/usr/bin/x11-ssh-askpass # Find an ssh password asker if [ ! -x "${SSH_ASKPASS}" ]; then PASSASKERS="gtk-led-askpass gnome-ssh-askpass x11-ssh-askpass" for I in ${PASSASKERS}; do if [ `which ${I} 2>/dev/null` ]; then export SSH_ASKPASS="`which ${I}`" break fi if [ -x /usr/libexec/openssh/${I} ]; then export SSH_ASKPASS="/usr/libexec/openssh/${I}" break fi if [ -x /usr/lib/openssh/${I} ]; then export SSH_ASKPASS="/usr/lib/openssh/${I}" break fi done fi # Make sure that our identity is available in ssh-agent source ~/.keychain/`hostname`-sh eval `keychain -q --eval id_dsa` ssh "$@"