LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   scp - peserve file ownership and permission (https://www.linuxquestions.org/questions/linux-newbie-8/scp-peserve-file-ownership-and-permission-106839/)

eyt 10-21-2003 03:56 PM

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.

Tinkster 10-21-2003 04:12 PM

I guess you'll need to pipe tar through
ssh to achieve that. scp doesn't "know"
about ownership.

Cheers,
Tink

eyt 10-21-2003 04:20 PM

Hi Tinkster,

But how to pipe tar through it as you have mentioned.

Tinkster 10-21-2003 04:32 PM

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 -"
Google for ssh & tar for examples ;)

Hope it helps.

Cheers,
Tink

eyt 10-21-2003 04:38 PM

Thanks.

Tinkster 10-23-2003 03:19 PM

And, got it working? :)

Cheers,
Tink

eyt 10-24-2003 03:41 PM

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.