rsync over ssh "error in protocol data stream" (code 12). ssh works
Matthew Martinez
I tried:
rsync -v -v -e 'ssh -p YY' ./testfile me@XXXXX:/homeError Message
opening connection using: ssh -p YY -l me 146.6.84.206 rsync ->-server -vvve.s . /home
[sender] make_file(testfile,*,0)
send_file_list done
send_files starting
server_recv(2) starting pid=17537
rsync: connection unexpectedly closed (9 bytes received so far) [sender]
rsync error: error in rsync protocol data stream (code 12) at io.c(600)[sender=3.0.6]
_exit_cleanup(code=12, file=io.c, line=600): about to call exit(12)This works fine:
ssh -p YY me@XXXXXWhich suggests to me the problem is neither that sshd is not running nor that port YY is firewalled. I have checked anyway.
What other problems could there be?
EDIT: The problem seems to have been "self resolving." I could not replicate the following day. I started my local computer up. Perhaps notably I had a different IP address than last time. And now rsync magically works. I'd appreciate guesses as to what it could have been in light of it going away.
59 Answers
You can also get this error if you specify a remote path that doesn't exist.
I got this error on OS X:
$ rsync -avz public/ static:apps/myapp.com
building file list ... done
rsync: connection unexpectedly closed (8 bytes received so far) [sender]
rsync error: error in rsync protocol data stream (code 12) at /BuildRoot/Library/Caches/(453) [sender=2.6.9]Turned it was simply a matter of mistyping the destination path. The apps dir didn't exist. When I changed that to static:sites/myapp.com instead (the sites dir did exist), the error went away.
It's fine if the final directory in the path doesn't exist (I could do static:sites/mynewapp.com) but it appears any preceding directory must already exist.
I got this error when rsync wasn't installed on the target host. The error message in my case also said rsync: command not found. A simple
sudo apt-get install rsyncon the target host solved the problem.
2Does your login script at the remote end produce garbage on stdout? Check this with
ssh -p YY me@XXXXX /bin/true > out.txtIf out.txt contains data, identify the offending statements in your .profile or .bashrc and wrap them in
if [ ! -t 1 ]; then echo garbage
fi 2 This error can also happen if the path to rsync at the remote system is not what the local system assumes it to be. You can see what is happening by specifying -vv (or even more vs). If this is the problem you can specify the remote path to rsync with the --rsync-path option.
2You may need to put in the full path to the ssh binary, ie
rsync -v -v -e '/usr/bin/ssh -p YY' ./testfile me@XXXXX:/homeThough there are other possible causes.
1I hit this error because I was rsyncing to a drive that was full! Check your disk usage if the other solutions here don't help you resolve this.
I happened to run into this error for a specific file's transfer because a previously aborted rsync run seems to have corrupted the destination file (maybe due to interrupted delta/incremental changes on the destination file).
My solution was to find out which file caused the error (by using -v and/or --progress), deleting that file in the destination, then running rsync normally again.
I was seeing this error:
rsync -e 'ssh -v'
debug1: Exit status 11...
rsync error: error in rsync protocol data stream (code 12) at /BuildRoot
/Library/Caches/(453)
[sender=2.6.9]I was able to ssh into the remote host and found that it was out of disk space.
I got this error in rsync protocol data stream (code 12) for a pair of rsync's with different versions. So please check the rsync versions on both client and server.
In my case, local rsync was version 2.6.9 (on Mac OSX), while remote one was version 3 (can't remember now the exact version). Once I upgraded my local rsync to version 3 (using brew), the problem was fixed.