where is SSH_AUTH_SOCK set?
I recently set up non-interactive ssh login from my machine (running Leopard) to a remote server using ssh keys and ssh-agent, but I'm not particularly happy with the solution. What I've had to do is explicitly set the SSH AUTHSOCK environment variable in a script launched by a cron job like this:
<pre>
export SSH AUTHSOCK=$(/usr/sbin/lsof | grep Listeners | grep ssh-agent | awk '{print $8}')
ssh -l someuser somehost.with.my.public.key "some command"
</pre>
As long as I've added the relevant private key for someuser using ssh-add since startup, unprompted login succeeds. I've noticed that if I log into my machine as someuser (ie, sitting in front of it), the SSH AUTHSOCK variable is set (even if I log out and log back in), but if I ssh in or run a cron job, it is not, and I have to set the variable explicitly as above.
Is there a more elegant solution than what I've done here? I'd rather configure non-interactive sessions so that I don't need to explicitly set SSH AUTHSOCK, but I can't figure out where in the logon process this variable is defined (someuser uses bash, but I'd like to be able to generalize to other shells). I'd also like to come up with a less fragile-seeming method of locating the "Listeners" socket file.
Thanks,
Noah
Mac OS X (10.5.4)