Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I usually use a graphical SSH client to sync a local and remote directory. And I have to set the ownership of all the files from root to www-data.

Can I do the same with Rsync, only that I do it as www-data instead of root, so that I dont have to set the ownership afterwards?

share|improve this question
add comment

2 Answers

It's not clear what you want to do, so let me assume that you want the local files to be owned by user A and the remote files to be owned by user B. If you run the following command as user A:

rsync [options] B@remote.system:/path/to/remote/dir /path/to/local/dir

this would have the effect you want. But it's not really an rsync issue (so I'm not elaborating on what the above command will do, I'm focusing on your question); even with your graphical SSH client you should be able to do the same if you run it as user A and set it to log on to the remote system as user B.

share|improve this answer
add comment

if you can sudo -u www-data then you can run rsync with that user. if your destination is on a different server, then you also need to set --rsync-path to the same (sudo -u www-data rsync). you also need to work around the tty issue (by using -t in your ssh), although depending on your distribution and ssh server settings, it could be very tricky. personally i think it is easier just to use root and do a chown afterwards, unless the server does not permit remote root login.

share|improve this answer
add comment

Your Answer

 
discard

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.