scp - peserve file ownership and permission
Hi all,
How to copy files and directory and preserves its ownership and permission using scp I tried to use the option -p but it doesn't work. I want to copy the local directory (directory_a) to the remote machine's /home directory and using the following command: scp -rp /local/directory_a root@remote_machine:/home The directory and its associated files were copied to the remote machine but the ownership of the files and directories changes to root:root. |
I guess you'll need to pipe tar through
ssh to achieve that. scp doesn't "know" about ownership. Cheers, Tink |
Hi Tinkster,
But how to pipe tar through it as you have mentioned. |
I don't know EXACTLY off the top of my head,
but it should look something like: Code:
tar czf - <directory> | ssh <user@host> "cd <target direcotry>; tar xzf -" Hope it helps. Cheers, Tink |
Thanks.
|
And, got it working? :)
Cheers, Tink |
I do the following and it works :
tar -cf -<directory> | ssh user@host tar -xf- -C<target directory> |
All times are GMT -5. The time now is 03:44 AM. |