I first saw this on an OpenSSH 4.2 installation, so we pulled down 5.1p1
and see the same thing. On linux hosts, the status will be 255
sometimes if it has stdin redirected to /dev/null. But only the status
is wrong. The connection is working and all the data comes back.

$ /usr/local/bin/ssh testg5 perl -v < /dev/null > /dev/null ; echo $?
0
$ /usr/local/bin/ssh testg5 perl -v < /dev/null > /dev/null ; echo $?
255
$ /usr/local/bin/ssh testg5 perl -v < /dev/null > /dev/null ; echo $?
0
$ /usr/local/bin/ssh testg5 perl -v < /dev/null > /dev/null ; echo $?
255
$ /usr/local/bin/ssh testg5 perl -v < /dev/null > /dev/null ; echo $?
255

Just on a lark I tried adding '-n' to the ssh line. It didn't make any
difference. If I don't redirect STDIN, then I get status 0 every
single time.

This is causing an automated testing framework to think that the ssh
connection has failed, when it's just fine.

If I capture a -vvv output from a "good" and "failed" connection,
there's very little difference.

diff /tmp/ssherr*
41a42
> debug1: client_input_channel_req: channel 0 rtype exit-status reply 0

48c49
< debug1: Exit status -1
---
> debug1: Exit status 0


Any ideas about what is happening here or more usefully, how I can fix
this? The framework I have will always redirect STDIN. I can't rewrite
it to avoid that bit.

Thanks for any help!!

--
Darren