#!/bin/sh agentpid=`ps -xwwwo pid,command | grep ssh-agent | head -1 | awk '{print $1}'` if [ -z "$agentpid" ]; then echo "No agent PID found" >&2 exit 1 fi agentsock=`sockstat | grep $agentpid | grep /tmp/ssh- | head -1 | awk '{print $6}'` if [ -z "$agentsock" ]; then echo "No agent socket found" >&2 exit 1 fi shell=`basename $SHELL` case $shell in *csh) echo "setenv SSH_AUTH_SOCK $agentsock" ;; *) echo "export SSH_AUTH_SOCK=$agentsock" ;; esac