Skip to content
Latchkey

rsync "protocol version mismatch": Unclean Shell

The "protocol version mismatch -- is your shell clean?" error means the remote login printed text before rsync could start its protocol handshake.

This classic rsync-over-SSH error in CI almost always traces to a banner, motd, or echo in the remote shell startup, not to actual rsync versions.

What it does

rsync expects the SSH channel to carry only its protocol bytes. If the remote shell prints anything (a login banner, motd, "Welcome" text, or a stray echo in .bashrc / .profile) those bytes land in the stream and rsync reads them as a bad protocol version. The message is misleading: the rsync versions are usually fine.

How to diagnose

Terminal
# This should print ONLY rsync version text, nothing else
ssh user@host rsync --version

# If you see a banner or extra lines first, the shell is not clean

Common fixes

Source of noiseFix
Echo/printf in .bashrcGuard interactive-only output with [ -t 1 ]
Login banner / motdDisable PrintMotd / Banner for the deploy user
fortune or neofetch on loginRemove from non-interactive startup
Shell prints to stdoutRedirect such output to stderr or guard it

In CI

Make non-interactive shells silent. In .bashrc, return early for non-interactive sessions: **case $- in *i*) ;; *) return;; esac**. Any "echo" that must run on login should write to stderr (>&2), not stdout, so it stays out of the rsync channel.

Common errors in CI

The exact strings are "protocol version mismatch -- is your shell clean?" and often "(see the rsync manpage for an explanation)" followed by "rsync error: protocol incompatibility (code 2)" or a code 12 stream error. The fix is to silence the remote shell, not to reinstall rsync.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →