Why is this rsync connection unexpectedly closed on Windows?

参考:SO: Why is this rsync connection unexpectedly closed on Windows?

rsync.exe -avz -e 'ssh -p 22' [email protected]:/home/user/testfile
[email protected]'s password:
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: error in rsync protocol data stream (code 12) at io.c(226) [sender=3.1.2]
rsync: [Receiver] safe_read failed to read 4 bytes: Connection reset by peer (104)
rsync error: error in rsync protocol data stream (code 12) at io.c(283) [Receiver=3.2.2]

原因:
ssh冲突造成的。

where ssh

D:\Programs\cwrsync_6.1.0\bin>where ssh
D:\Programs\cwrsync_6.1.0\bin\ssh.exe
C:\Windows\System32\OpenSSH\ssh.exe

解决方案:
方案1:指定ssh rsync.exe -avz -e './ssh -p 22' [email protected]:/home/user/testfile

方案2:设定运行环境
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 %*

你可能感兴趣的:(Why is this rsync connection unexpectedly closed on Windows?)