`rsync -az ./dist/ deploy@web1:/srv/app/` fails with `protocol version mismatch -- is your shell clean?`, while `ssh deploy@web1` works fine.
AdvancedTroubleshootingTroubleshooting: tools, portability, permissions and environment
Answer
Likely causes → rsync speaks its protocol over the SSH channel. Something in the remote user's shell start-up files (~/.bashrc, /etc/bash.bashrc) prints output even for non-interactive shells: an echo "Welcome", a fortune, a version banner. That text corrupts the protocol stream. scp with the legacy protocol fails the same way.
Diagnose →
ssh deploy@web1 /bin/true | od -c | head # anything printed here is the culprit
Fix → Guard interactive-only output in the remote rc files:
# top of ~/.bashrc
case $- in *i*) ;; *) return ;; esac
Prevent → Keep shell start-up files silent for non-interactive shells, and give automation accounts a minimal, managed .bashrc.
More on Troubleshooting: tools, portability, permissions and environment
On a Mac, `sed -i 's/replicas: 2/replicas: 3/' deploy.yaml` fails with `sed: 1: "deploy.yaml": extra characters at the end of d command`.BeginnerA cleanup script fails on a developer's Mac with `date: illegal option -- d`.BeginnerA script that works on Ubuntu fails in an Alpine-based CI image with `grep: unrecognized option: P`.IntermediateAn `awk` one-liner works on your RHEL box but fails on Ubuntu with `awk: line 1: function gensub never defined`.Intermediate`comm -23 expected.txt installed.txt` prints `comm: file 1 is not in sorted order`, even though both files were produced with `sort`.Intermediate`grep ERROR /var/log/app/app.log` prints only `grep: /var/log/app/app.log: binary file matches`.Beginner