When you run ssh-agent it starts and prints its own pid, even if an agent is already running. The -k flag can be used to kill the existing agent, but it would be useful to have a flag (-e for example) which just prints the details of the existing agent if running (and if there is no existing agent, starts up as normal). Then you could always do in the shell eval `ssh-agent -e` and it would make sure an agent was running, starting one if necessary, but leaving the existing one in place otherwise. This can of course be done with shell scripting but I think it would be a useful feature for ssh-agent itself.
This can be done by checking the $SSH_AGENT_PID and $SSH_AUTH_SOCK environment variables already. E.g. in .bash_profile (or equivalent) test -z "$SSH_AUTH_SOCK" && eval `ssh-agent` ... and in .bash_logout: test -z "$SSH_AGENT_PID" || kill $SSH_AGENT_PID This typically does what the user wants: start and agent if no agent exists already (e.g. by being forwarded or started by a desktop session), but only kill an agent that was started within the session. I don't therefore think it necessary to implement this in ssh-agent itself.
closing resolved bugs as of 8.6p1 release