Hi,
the often called question: Can I run rsync on Windows by using the putty agent?
Answer: Yes, but there a some steps to setup such an environment.
I’m assuming you aleady have putty installed at your computer. In this example the putty tools like plink etc. are downloaded to D:\tools\putty.
First of all install cygwin’s rsync:
- Download install cygwin it from the Internet
- Choose a (root) Install directory, i.e. D:\tools\cygwin
- Choose the directory where the files should downloaded to
- From the packages list choose
Net / rsync (latest version, here 3.2.3)
Devel / gcc-core (latest stable version, here 10.2.0) - Add an Icon to the startmenu to be able to start the cygwin terminal
when the installation finishs rsync could be found at
D:\tools\cygwin\bin\rsync.exe
Then you need cygnative because there is an incompatibility of stdin/stdout redirection between cygwin and native Win32 programs. I will place it in the putty directory (curl is already included in newer Windows 10 releases)
Download cygnativ source
D:\> cd D:\tools\putty
D:\tools\putty> curl https://raw.githubusercontent.com/davidecolombo/cygnative/master/cygnative.c -o cygnative.c
If you want to call cygwin commands (gcc, rsync) from a cmd shell you must add the cygwin bin folder and the putty folder to the path variable otherwise you have to specify the full path (in cygwin notation) to cygnative and plink for the rsync -e (–rsh) parameter.
D:\tools\putty> set PATH=%PATH%;D:\tools\cygwin\bin;D:\tools\putty;
Compile cygnative
D:\tools\putty> D:\tools\cygwin\bin\gcc.exe cygnative.c -o cygnative.exe
D:\tools\putty> cygnative.exe
cygnative - a programm to use stdin/stdout redirection
on native win32 programms called from cygwin
(C) Copyright 2009, Frank Behrens, Version 1.2
Usage: cygnative [args...]
Now you can call rsync. The local directory must be given in cygwin notation. For D:\Temp you have to use /cygdrive/d/Temp/. Use the cygwin terminal to determine the correct path.
D:\tools\putty> rsync -args -e="cygnative plink" /cygdrive/d/Temp/ michael@10.10.254.100:/tmp
Michael
I have followed this closely but it does not seem to work for me. I have Windows 10 Enterprise and server is running CentOS Red Hat 4.8.5-44.
rsync -avz -e=”cygnative plink” /cygrdive/d/Tempfils/halo.txt samuel@10.97.133.192:/home/samuel/
protocol version mismatch — is your shell clean?
(see the rsync manpage for an explanation)
rsync error: protocol incompatibility (code 2) at compat.c(622) [sender=3.2.7]
FATAL ERROR: Error reading from console: Error 109: The pipe has been ended.
could not write to parent
If I run just:
rsync -avz /cygrdive/d/Tempfils/halo.txt samuel@10.97.133.192:/home/samuel/
samuel@10.97.133.192‘s password: **********
rsync: connection unexpectedly closed (0 bytes received so far) [Receiver]
rsync error: error in rsync protocol data stream (code 12) at io.c(605) [Receiver=3.0.9]
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: error in rsync protocol data stream (code 12) at io.c(231) [sender=3.2.7]
Any idea what could be wrong please?