reference counting in ssh-agent?

Darren Tucker dtucker at
Fri Jul 29 00:46:33 EST 2005

Rob wrote:
> Problem: when I log out, the ssh-agent process persists which is the
> correct behavior in some cases, but not in others.  This means that
> periodically I have to kill off hundreds of ssh-agent processes as they
> are taking up a substantial amount of my (fairly old) machine's resources.
> Question: is there a trivial way of fixing this problem?

Yes, don't do that.  :-)

> I could do some
> shell scripting to kill ssh-agent in the right cases and not in others,
> but that seems kludgy, and I can't imagine that I'm the only one to have
> this problem.

if [ ! -e ~/.ssh/myagentsock ]; then
         ssh-agent -a ~/.ssh/myagentsock >~/.ssh/myagent
. ~/.ssh/myagent

or google for "ssh keychain"

> Better question: if I were to write a patch to openssh that implemented
> reference counting in ssh-agent, would that be a Useful Idea?

Probably not.  It would complicate the agent unecessarily.

Darren Tucker (dtucker at
GPG key 8FF4FA69 / D9A3 86E9 7EEE AF4B B2D4  37C9 C982 80C7 8FF4 FA69
     Good judgement comes with experience. Unfortunately, the experience
usually comes from bad judgement.

More information about the openssh-unix-dev mailing list