retain ownership

Hi,
I have a script which transfers files/directories from one HP unix to another HP unix server using SCP but i need to retain ownership of files/folders same as source server my script is as follows

 
cd /sasdata/TR_CNTO328/C0328T07/Dry_Run_1/Macros
find . -type d -newer . -exec scp -pr {} sasadmin@targetserver:/sasdata/TR_CNTO328/C0328T07/Dry_Run_1/Macros ';'

,
permission,timestamp remains same as source server but ownership of files/folders getting changed,I need to know why this is happening or is there any parameter which i need to mention in my script.

As per the man scp (scp) manual page, the -p option does not preserve ownership. And this makes sense, as the user "sasadmin" is the owner of the destination. If you can log into the destination system as root, you could use man tar (linux) or man cpio (linux) to preserve ownership.

Hi
Thanks for reply i have to use scp only. then how to preserve ownership in scp
any help will be appriciated

Thanks and Regards

You don't.

Create a tarball and copy it over with scp. The tar files will preserve ownership when root extracts them.

use rsync over ssh

man rsync (linux) is an alternative way to copy files from system to system - but it uses man ssh (linux) to make the connection. And it will not preserve ownership unless you are connecting as root on the destination system.

Another alternative is nfs and its ilk - sharing out a directory would preserve ownership -- by UID.

thank you all for your response i just got to know that one can not retain ownership of file/directory while SCP!!!