ssh-agent subprocess parentage

Phil Pennock phil.pennock at
Tue May 10 06:54:45 EST 2011

On 2011-05-09 at 12:06 -0400, Daniel Kahn Gillmor wrote:
> I regularly use ssh-agent with a subcommand; my X11 session is spawned
> through ssh-agent, and sometimes i'll run a special agent for a certain
> subset of commands, like this:
>  ssh-agent bash
>  ... and then do work within that shell.  From the man page:
> >      If a commandline is given, this is executed as a subprocess of the agent.
> >      When the command dies, so does the agent.
> But looking at the process table (and at ssh-agent.c) this isn't what
> actually happens.
> It looks like the agent lives on as the subprocess, and the subcommand
> is execed from the parent process.

No, that's not how Unix works.  A child process can't indirectly cause
its parent to run something without pre-arranged RPCs to communicate
application-layer instructions to do so, which I doubt your shell has.

There is a common idiom to use:
  eval `ssh-agent -s`
to set up ssh which results in the process layout you describe.  This is
probably happening somewhere that you just haven't tracked down yet.

If you really can't track it down, mv ssh-agent to ssh-agent.real and
write a wrapper-script which calls pstree, writing the output to a
log-file, before exec'ing ssh-agent.real and wait for that to track it

More information about the openssh-unix-dev mailing list