[openssh-unix-dev] Re: using ssh-add unattended on dubious files -- how can i avoid a

David Bronder david-bronder at uiowa.edu
Thu Aug 21 10:00:46 EST 2008

Daniel Kahn Gillmor wrote:
> On Wed 2008-08-20 18:27:59 -0400, Jim Knoble wrote:
> > Have you tried running ssh-add via setsid(1)?
> Thanks, Jim!  I didn't know about setsid, and it appears to be what
> i'm looking for.
> The only remaining irritation is that ssh-add returns a status code of
> 0 rather than the expected non-zero value from a failed attempted add
> under setsid.

Actually, that isn't really working, either.  The ssh-add is still
running and grabbing /dev/tty even though you get your prompt back
(check ps from another shell).  It will eat terminal input until the
next newline even though you don't see the prompt.  The 0 exit code
is coming from setsid, which had no errors.

Instead, try setting SSH_ASKPASS to /bin/false or DISPLAY to a bogus
value, and redirect/close stdin/stdout/stderr.  That will make ssh-add
try to use SSH_ASKPASS which will fail (one way or another).

  $ SSH_ASKPASS=/bin/false ssh-add foo </dev/null >/dev/null 2>&1
  $ DISPLAY=bar ssh-add foo </dev/null >/dev/null 2>&1


Hello World.                                    David Bronder - Systems Admin
Segmentation Fault                                     ITS-SPA, Univ. of Iowa
Core dumped, disk trashed, quota filled, soda warm.   david-bronder at uiowa.edu

More information about the openssh-unix-dev mailing list