I'm sure you remember what you asked on ssh more than half a
year ago? :-)
On Tue, 17 Nov 1998, Roman Maeder wrote:
> I am observing occasional cases where an ssh connection returns before
> the
> remote pipe has finished its output, resulting in loss of the end of the
> remote output. I have been able to reproduce it with something as simple
> as
>
> ssh remotehost "cat huge_file | gzip -5" | gunzip -vt
>
> where huge_file was a 2MB file that compressed well (a HTTP log), and
> the
> connection was over an ISDN line (7kBps max). My real application would
> use "ufsdump" instead of "cat", and add an SSLeay encryption to the
> end. It doesn't seem to happen with shorter files, or fast local
> ethernet
> connections, and it doesn't happen always. I use ssh 1.2.16; the local
> and remote machines run Solaris 2.5.1.
>
> Has anybody seen this too, or any ideas how to make ssh wait until the
> remote pipe is really done?
>
> Roman Maeder
Yes, I have the same problem.... I have been able to reproduce
it in several different ways. My real app is this (with fix
added in):
cd /
find proj -depth -print0 | ( cpio -0oaB -H crc ; \
dd if=/dev/zero bs=512 count=1 2>/dev/null ) | \
ssh2 -l root ruth '( cd /fscd ; cpio -idum -H crc )'
The drawback is 512 confusing nullbytes at the end of the
transmission. I use ssh-1.2.23. I am just now in the process
of running the above command over a local 10 Mbps ethernet --
yes, all of my problems have been equally bad on a 10 Mbps
switched local ethernet as over modem. The above command will
copy roughly 1.5 GB of files and directories, so I'll get back
with the result tomorrow. So far I've verified using different
cpio commands and flags that without the "dd" command, the
process always fails -- except when using the -c flag to cpio,
which causes lots of error messages, which happens to supply the
extra bytes needed to pad the transmitted data. (Note that a
glibc-related bug in cpio must be fixed before glibc-users can
repeat this command -- my cpio has been fixed.)
I have also tried this command:
ssh2 -l root ruth.swip.net \
'( cd /usr/src ; find . -type d -print )' \
2>&1 | tee /tmp/files-as-root
The above command terminated abnormally -- no error message, but
the pipe must have closed early or something, because this is
the first and last lines of /tmp/files-as-root, I have quoted
the section between "START>" and "<END" (minus the """):
START>.
./packages
./packages/BUILD
./packages/RPMS
./packages/RPMS/i386
./packages/SOURCES
[omitting lots of complete lines for brevity]
./sendmail-8.9.3/BuildTools/M4/depend
./sendmail-8.9.3/BuildTools/OS
./sendmail-8.9.3/BuildTools/Site
./sendmail-8.9.3/doc
./sendmail-8.9.3/doc/op
./sendmail-8.9.3/doc/changes
./sendmail-8.9.3/doc/intro
./sendmail-8.9.3/d<END
Executing the command locally on ruth.swip.net, the result is
quite different, 485 additional bytes worth of different!:
su -
( cd /usr/src ; find . -type d -print ) 2>&1 | tee /tmp/files-as-root
chown leif:adm /tmp/files-as-root
This is the first and last lines of /tmp/files-as-root, I have
quoted the section between "START>" and "<END" (minus the """):
START>.
./packages
./packages/BUILD
./packages/RPMS
./packages/RPMS/i386
./packages/SOURCES
[omitting lots of complete lines for brevity]
./sendmail-8.9.3/BuildTools/M4/depend
./sendmail-8.9.3/BuildTools/OS
./sendmail-8.9.3/BuildTools/Site
./sendmail-8.9.3/doc
./sendmail-8.9.3/doc/op
./sendmail-8.9.3/doc/changes
./sendmail-8.9.3/doc/intro
./sendmail-8.9.3/doc/usenix
./sendmail-8.9.3/mail.local
./sendmail-8.9.3/mailstats
./sendmail-8.9.3/makemap
./sendmail-8.9.3/smrsh
./sendmail-8.9.3/src
./sendmail-8.9.3/test
./sendmail-8.9.3/cf
./sendmail-8.9.3/cf/cf
./sendmail-8.9.3/cf/domain
./sendmail-8.9.3/cf/feature
./sendmail-8.9.3/cf/hack
./sendmail-8.9.3/cf/m4
./sendmail-8.9.3/cf/mailer
./sendmail-8.9.3/cf/ostype
./sendmail-8.9.3/cf/sh
./sendmail-8.9.3/cf/siteconfig
./sendmail-8.9.3/praliases
./sendmail-8.9.3/rmail
./sendmail-8.9.3/contrib
<END
Please note that 485 bytes is less than 512 bytes, a common size
for a buffer. Seems that the last buffer isn't always
transmitted by ssh2 !!!
A workaround might be to always transmit an additional 512 byte
of dummy information after the real stuff.
Let's try it out....
ssh2 -l root ruth.swip.net \
'( cd /usr/src ; find . -type d -print ; \
dd if=/dev/zero bs=512 count=1 2>/dev/null )' \
2>&1 | tee /tmp/files-as-root
The /tmp/files-as-root was this time correct, with 512 nulls in
the end (not 485). But the screen output lacked half the file!
Straaaange! :-)
I tried it again -- this time the screen output ended in a
different place. The nulls must be confusing! File still
correct though, and still 512 nulls in the end (not 485).
Hope this helps someone! I'll report in the result of the cpio
later, but I have all confidence that this fix will be just what
the doctor ordered. PS: Is there someone who knows what is the
matter with ssh2, that makes it close down the pipe early?!
Thanks,
________________________________________________________________
Leif Erlingsson, Katrinebergsvagen 70, 146 50 Tullinge, Sweden
TEL +46 8 778-5038, MOB +46 709 14-0631, URL http://www.lege.com
"Now playing at a data center near you: Software Wars, starring
Scott McNealy as Luke Javawalker, Bill Joy as Jini-Wan-Kenobi,
and James Gosling as Code-a. Also featuring Steve Ballmer as
Darth Windows, Bill Gates as the evil Emperor and a cast of 1000
marketing executives as Imperial Stormtroopers."
(Michael Vizerd, Infoworld)