# rsync ssh Userrights

**URL:** <https://forums.suse.com/t/rsync-ssh-userrights/22795>\
**Category:** SLES Configure-Administer\
**Created:** [June 28, 2012, 9:38pm UTC](https://forums.suse.com/t/rsync-ssh-userrights/22795 "2012-06-28T21:38:57Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![maccinx](https://avatars.discourse-cdn.com/v4/letter/m/898d66/32.png) [@maccinx](https://forums.suse.com/u/maccinx)\
**Post date:** [June 28, 2012, 9:38pm UTC](https://forums.suse.com/t/rsync-ssh-userrights/22795/1 "2012-06-28T21:38:57Z")

</div>

Hi there,

i have two SLES Server and want to sync my Website on Sourcemachine /srv/www/htdocs/mySite/ to the other Targetmachine same Directory /srv/www/htdocs/mySite/.  
On the Sourcemachine all Files have the User wwwrun Group www. After sync with rsync the Rights on the Targetmachine changed to sshUser:www.  
Here my rsync Command:  
rsync -avze ssh /srv/www/htdocs/mySite/ sshUser@targetmachine:/srv/www/htdocs/mySite/.  
I thought with -a the rights are transfered to.

Can`t find what i`m missing.

any ideas?

maccinx:cool:

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex022/uploads/suse/original/2X/5/5012ba89e3ffb5220dac47d5ea0ba032e2fe1cb6.png) [@system](https://forums.suse.com/u/system)\
**Post date:** [June 29, 2012, 1:05am UTC](https://forums.suse.com/t/rsync-ssh-userrights/22795/2 "2012-06-29T01:05:48Z")

</div>

On Thu, 28 Jun 2012 18:44:01 +0000, maccinx wrote:  
[color=blue]

> On the Sourcemachine all Files have the User wwwrun Group www. After  
> sync with rsync the Rights on the Targetmachine changed to sshUser:www.[/color]

Does the user wwwrun exist on the target machine?

If it does, does it have the same UID?

## Jim

Jim Henderson, CNA6, CDE, CNI, LPIC-1, CLA10, CLP10  
Novell Knowledge Partner

---

<div class="post-metadata">

**Author:** ![maccinx](https://avatars.discourse-cdn.com/v4/letter/m/898d66/32.png) [@maccinx](https://forums.suse.com/u/maccinx)\
**Post date:** [June 29, 2012, 12:02pm UTC](https://forums.suse.com/t/rsync-ssh-userrights/22795/3 "2012-06-29T12:02:05Z")

</div>

yes User wwwrun UID 30 are Systemusers on both Machines. I even thought about given wwwrun a passwort and use this user to connect via ssh wwwrun@targetmachine. But i think this is not a clever idea.

---

<div class="post-metadata">

**Author:** ![enovaklbank](https://avatars.discourse-cdn.com/v4/letter/e/aca169/32.png) [@enovaklbank](https://forums.suse.com/u/enovaklbank)\
**Post date:** [June 29, 2012, 6:08pm UTC](https://forums.suse.com/t/rsync-ssh-userrights/22795/4 "2012-06-29T18:08:59Z")

</div>

-o, --owner  
This option causes rsync to set the owner of the destination file to be the same as the source file, but only if the receiving rsync is being run as the  
super-user (see also the --super and --fake-super options). Without this option, the owner of new and/or transferred files are set to the invoking user on the  
receiving side.

---

<div class="post-metadata">

**Author:** ![Jens-U](https://avatars.discourse-cdn.com/v4/letter/j/d78d45/32.png) [@Jens-U](https://forums.suse.com/u/Jens-U)\
**Post date:** [July 2, 2012, 2:50pm UTC](https://forums.suse.com/t/rsync-ssh-userrights/22795/5 "2012-07-02T14:50:25Z")

</div>

Hi maccinx,

as has been pointed out by enovaklbank, the problem is that an ordinary user may not change file ownership. As you connect to the target server as “sshUser”, that’s the context you get and the reason why only scp within the root user context can effectively use “–owner”.

But rather than setting a password for wwwrun or even connecting as root, here’s another way to skin that cat: If it’s not necessary to trigger the transfer from sourcemachine, why not run the scp copy from targetmachine (“pull” instead of “push”), from the user wwwrun? As the files on sourcemachine are probably world-readable anyhow, you can use a low-privilege user on that machine to _read_ the files, and as you’re running in a wwwrun context on targetmachine, you’ll be able to _write_ the files with the proper ownership.

> I even thought about given wwwrun a passwort and use this user to connect via ssh wwwrun@targetmachine. But i think this is not a clever idea.

You should use at least public key authentication, rather than setting (and using) passwords. Especially in automated environments, that’s much easier to handle…

Regards,  
Jens

---

<div class="post-metadata">

**Author:** ![maccinx](https://avatars.discourse-cdn.com/v4/letter/m/898d66/32.png) [@maccinx](https://forums.suse.com/u/maccinx)\
**Post date:** [July 2, 2012, 3:51pm UTC](https://forums.suse.com/t/rsync-ssh-userrights/22795/6 "2012-07-02T15:51:14Z")

</div>

ah i see, running a pull on the targetmachine as wwwrun may solve my problem. IÂ´ll give it a try.  
And of course i use public key authenification 😉
