Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I seem to come up against this issue occasionally:

serverA assets:
owned by user: apache
(no 'ftp' user present)

serverB assets:
owned by user: ftp
(apache user present, but not used)

I connect to serverA as root, then rsync over ssh to serverB as root. After which, all the assets on serverB are owned by either root or apache, depending on whether or not I tell rsync to preserve the ownership that the files have on serverA.

Anyone have any tricks for changing ownership of rsync'ed files on serverB to an alternate user, one that is not the owner on serverA and is not the user issuing the rsync command? The resulting files on serverB would be owned by the 'ftp' user.

In the past, I've always just followed the command with a recursive chown, but I'd like to find a way to do this in rsync, or get it down to a single command.

share|improve this question

Try setting RSYNC_RSH to "ssh -o 'User apache'"
and/or using --rsync-path='su apache -c rsync'
or patch the rsync source to support setting abitrary users.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.