55

I'm trying to use rsync on Windows 7. I installed cwRsync and tried to connect to Ubuntu 9.04.

$ rsync -azC --force --more-options ./ user@server:/my/path/
rsync: connection unexpectedly closed (0 bytes received so far) [receiver] 
rsync error: error in rsync protocol data stream (code 12) at io.c(600) [receiver=3.0.5]
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: error in rsync protocol data stream (code 12) at io.c(610) [sender=3.0.8]
Anthony Mastrean
  • 21,850
  • 21
  • 110
  • 188
rkmax
  • 17,633
  • 23
  • 91
  • 176
  • 2
    This error seems to be a catch all. It also occurs if you specify the destination file name for a file, instead of just the directory. – Nick May 31 '14 at 01:30
  • 4
    This might be late, but adding for posterity. The filesystem where the files are synced to has reached 100% disk space. – bram Feb 20 '15 at 01:21

6 Answers6

38

The trick for me was I had ssh conflict.

I have Git installed on my Windows path, which includes ssh. cwrsync also installs ssh.

The trick is to have make a batch file to set the correct paths:

rsync.bat

@echo off
SETLOCAL
SET CWRSYNCHOME=c:\commands\cwrsync
SET HOME=c:\Users\Petah\
SET CWOLDPATH=%PATH%
SET PATH=%CWRSYNCHOME%\bin;%PATH%
%~dp0\cwrsync\bin\rsync.exe %*

On Windows you can type where ssh to check if this is an issue. You will get something like this:

where ssh
C:\Program Files (x86)\Git\bin\ssh.exe
C:\Program Files\cwRsync\ssh.exe
Petah
  • 45,477
  • 28
  • 157
  • 213
  • 2
    Also was having problems with github's git client's shell ssh version. Doing an `apt-cyg install openssh` fixed this for me. If unsure if you have this problem try `which ssh` from a cygwin prompt. – Krzysztof Bociurko Aug 20 '15 at 20:48
  • Or `where ssh` from you Windows CLI – Petah Aug 20 '15 at 21:18
  • Hi, I'm sorry, it look like I have the same probleme, but my poor knowledge about computer environment does'nt help me fix this one : http://stackoverflow.com/questions/32756423/rule-conflict-between-multiple-ssh Thanks – leonsaysHi Sep 24 '15 at 09:31
  • 1
    +1. I was using cygwin and having the same problem. I found an even easier way to solve this paths issue, just do `SET PATH=C:\cygwin\bin;%PATH%` i.e. *pre*pend the cygwin's (or cwrsync's) path before all paths (automatically including git's paths). – laggingreflex May 13 '16 at 20:26
  • cwrsync comes with a `cwrsync.cmd` file now, which sets this up.. you can add `rsync` commands at the end of the file and they will work, or maybe `call` it before using rsync in a cmd prompt – Claudiu Oct 06 '17 at 17:21
  • 1
    For me, it wasn't a conflict of multiple `ssh`, but rather not having the correct one installed with Cygwin. So I had a version in `C:\Windows\System32\OpenSSH\ssh.exe` but I didn't have the proper Cygwin version: `C:\cygwin64\bin\ssh.exe`. Simply installing the `openssh` component in Cygwin fixed my issue! – Mike Weir Jul 30 '21 at 20:47
22

I saw this when changing rsync versions. In the older version, it worked to say:

rsync -e 'ssh ...

when the rsync.exe and ssh.exe were in the same directory.

With the newer version, I had to specify the path:

rsync -e './ssh ...

and it worked.

Jess
  • 23,901
  • 21
  • 124
  • 145
Seth Wegner
  • 221
  • 2
  • 3
7

I had this problem, but only when I tried to rsync from a Linux (RH) server to a Solaris server. My fix was to make sure rsync had the same path on both boxes, and that the ownership of rsync was the same.

On the linux box, rsync path was /usr/bin, on Solaris box it was /usr/local/bin. So, on the Solaris box I did ln -s /usr/local/bin/rsync /usr/bin/rsync.

I still had the same problem, and noticed ownership differences. On linux it was root:root, on solaris it was bin:bin. Changing solaris to root:root fixed it.

Mark
  • 71
  • 1
  • 2
  • 6
    If the remote rsync binary is in an unusual location you can specify it: rsync -azC --rsync-path=/usr/local/bin/rsync ... for example. – dr-jan Mar 26 '13 at 15:55
6

I had this error coming up between 2 Linux boxes. Easily solved by installing RSYNC on the remote box as well as the local one.

davidgo
  • 269
  • 4
  • 10
  • Yea, it would be nice if rsync could be more descriptive about the error. I received the exact same error message produced by all the other "Answers" to this question, but mine was for yet another basic problem ... file permission and ownership of the destination directory on a linux box. Didn't discover until after verifying that I didn't have any of the other problems mentioned on this Answer (rsync path, bin version mismatch, bin permissions, ssh path, etc). – hobs Feb 19 '14 at 22:46
4

This error message probably means that you either mistyped the server name or forgot to start an ssh server at server. Make absolutely certain that an ssh server is running on the server at port 22, and that it's not firewalled. You can test that with ssh user@server.

phihag
  • 278,196
  • 72
  • 453
  • 469
  • nop the server works fine and the name is correct the scp command and ssh command work fine too – rkmax Sep 01 '11 at 17:43
  • @rkmax Updated the answer with other possible causes, but if ssh works, those don't apply either. Can you try an rsync without any unnecessary parameters and then upload a packet dump, for example generated with [wireshark](http://wireshark.org/)? – phihag Sep 01 '11 at 18:19
  • yes the server listening on 22 port and ran the command with only from_dir and user@host:to_dir and get the same message – rkmax Sep 01 '11 at 18:59
  • @rkmax Can you post a link to a packet dump? – phihag Sep 01 '11 at 19:01
  • @phihang can you tell me how doing? – rkmax Sep 01 '11 at 19:33
  • 1
    @rkmax Install wireshark (linked above), start a packet capture, execute rsync, stop packet capture, save the file somewhere, and then upload it and link to it. This will point out any network problems, which I'm suspecting. Alternatively (or additionally), you can install strace and run `strace -o rsync.strace -s 100 -f rsync user@server` and upload the file `rsync.strace` generated by that. This will give you an idea on the OS level (in contrast to the network level of wireshark) of what rsync is doing and possibly why it's failing. – phihag Sep 01 '11 at 19:43
  • Phihag i get the solution. i've using cygwin and this is the problem in the windows powershell the command work fine. thanks for helping – rkmax Sep 01 '11 at 20:36
  • @rkmax You should've mentioned that important fact. Nevertheless, feel free to post and accept your own answer, to help other people struggling with the same or similar problems. – phihag Sep 01 '11 at 20:39
  • to echo this answer, I had the hostname wrong when I was trying to connect in my case. –  Jun 01 '16 at 18:39
4

i get the solution. i've using cygwin and this is the problem the rsync command for Windows work only in windows shell and works in the windows powershell.

A few times it has happened the same error between two linux boxes. and appears to be by incompatible versions of rsync

rkmax
  • 17,633
  • 23
  • 91
  • 176
  • This also happens if rsync on destination server does not exist. – Richard - Rogue Wave Limited May 31 '17 at 17:47
  • 4
    I had the same problem with cygwin and rsync. In my case I had installed Git for Windows and it had placed its own openssh implementaiton first in the PATH (at `/cygdrive/c/Windows/System32/OpenSSH/ssh`). By adding the rsync option `--rsh /cygdrive/c/cygwin64/bin/ssh`I could use the cygwin openssh implementation that does not give the error message. – Lennart Schedin Dec 26 '18 at 14:49