reference counting in ssh-agent?

Rob capveg at
Thu Jul 28 06:52:24 EST 2005


In a machine that I regularly use one console and remotely I have the line:

eval `ssh-agent`

In my .login, as per the ssh-agent(1) man page.

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?  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.

Better question: if I were to write a patch to openssh that implemented
reference counting in ssh-agent, would that be a Useful Idea?   I was
thinking something like when a shell creates a new process, then ref=1,
if the current shell finds an existing process, send that process a signal
to increment ref, and in .logout, decrement ref and have ssh-agent exit
if ref=0.  Presumably I could find some sort of unused signal in ssh-agent
(SIGUSR1 or some such), and this seems reasonably secure.

Please let me know what people think: thanks,

- Rob

PS Pls make sure to CC me as I am not subscribed to the list.

More information about the openssh-unix-dev mailing list