#!/bin/sh # # $Id: reagent,v 1.3 2005/09/21 16:44:08 jmates Exp $ # # The author disclaims all copyrights and releases this script into the # public domain. # # Starts and configures the ssh-agent(1) utility. Kills ssh-agent if # found running already. Uses my allsh utility to reconfigure any # running shells with the new ssh-agent details. # TODO portability problems of killall (e.g. Solaris?) killall -u `id -un` ssh-agent ssh-agent -s | grep -v echo > "$HOME/.ssh-agent" STATUS=$? if [ $STATUS -ne 0 ]; then echo "error: non-zero exit starting ssh-agent: status=$STATUS" >&2 exit $STATUS fi # if have tty, try to read in keys (which could prompt for passwords) if test -t 0; then . "$HOME/.ssh-agent" for private_key in $HOME/.ssh/id_*[^pub] $HOME/.ssh/identity; do if [ -f "$private_key" ]; then ssh-add "$private_key" fi done fi # this takes some time, so do it after above... allsh - < "$HOME/.ssh-agent"