I just spend approx. one hour to track down a nasty problem, caused by using ssh with authorized keys and forced command. This is for the records and hopefully will help others to solve the problem quicker.
When trying to move a working script to a different machine and a different user-account, my rsync-script failed with this message:
rsync error: protocol incompatibility (code 2) at io.c(1332) [sender=3.0.8] rsync: connection unexpectedly closed (2668 bytes received so far) [receiver] rsync error: error in rsync protocol data stream (code 12) at io.c(601) [receiver=3.0.7] rsync: connection unexpectedly closed (70 bytes received so far) [generator] rsync error: error in rsync protocol data stream (code 12) at io.c(601) [generator=3.0.7]
Now in this special constellation, there are many possible reasons, since the machines are quite different:
Server: Fedora 13, x86_64, openssh 5.4p1, rsync version 3.0.8 protocol version 30
Old client: Mageia 1, i686, openssh 5.8p1, rsync version 3.0.8 protocol version 30
New Client: Debian Squeeze, armv5tel, openssh 5.5p1, rsync version 3.0.7 protocol version 30
To make a long story short: The error message is absolutely misleading. The error is not caused by a protocol incompatibility, but simply by my forced command. And the error is simply triggered by using --dry-run.
When running rsync with --dry-run, obviously the command, which is send to the server, differs. Now the SSH-Server drops the connection, since the received command does not match the forced command. rsync get communication errors which it is misinterpreting and talking about "protocol incompatibility".