I'm running a rsync via apache to sync an assets directoryrsync -avz -e 'ssh -l rsync -i /home/rsync/.ssh/rsync -o StrictHostKeyChecking=no' /var/www/html/site/Uploads centos@$IP:/var/www/html/site/UploadsThis works correctly but the ownership changes from apache to centos as it's the user. I could setup the keys for the apache user however that user can't be logged in so that doesn't work.How can I get rsync to either run as apache to preserve the ownership or run as the centos user and maintain the owner as apache (cron won't work for my case).
rsync files with apache permissions over ssh
centos;permissions;apache httpd;rsync;php
So the best way I found is to have a user that has sudo access for only that command and use --rsync-path='sudo rsync'. e.g.:rsync -avz -e 'ssh -l rsync -i /home/rsync/.ssh/rsync -o StrictHostKeyChecking=no' /path/ --rsync-path='sudo rsync' rsync@xxx.xxx.xxx.xxx:/path/