LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 10-21-2003, 04:56 PM   #1
eyt
Member
 
Registered: Sep 2003
Posts: 76

Rep: Reputation: 15
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.
 
Old 10-21-2003, 05:12 PM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,066
Blog Entries: 11

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

Cheers,
Tink
 
Old 10-21-2003, 05:20 PM   #3
eyt
Member
 
Registered: Sep 2003
Posts: 76

Original Poster
Rep: Reputation: 15
Hi Tinkster,

But how to pipe tar through it as you have mentioned.
 
Old 10-21-2003, 05:32 PM   #4
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,066
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
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
 
Old 10-21-2003, 05:38 PM   #5
eyt
Member
 
Registered: Sep 2003
Posts: 76

Original Poster
Rep: Reputation: 15
Thanks.
 
Old 10-23-2003, 04:19 PM   #6
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,066
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
And, got it working? :)

Cheers,
Tink
 
Old 10-24-2003, 04:41 PM   #7
eyt
Member
 
Registered: Sep 2003
Posts: 76

Original Poster
Rep: Reputation: 15
I do the following and it works :

tar -cf -<directory> | ssh user@host tar -xf- -C<target directory>
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
File Ownership chrisfirestar Linux - General 2 11-10-2005 05:41 AM
Strange permission issue. Problems changing ownership. ExCIA Linux - Newbie 6 05-26-2005 05:17 AM
Ownership/Permission and Delete Syntax MadDogE134 Linux - Newbie 8 06-09-2004 07:05 PM
CVS - file permissions and file ownership Osten Linux - Software 3 01-18-2004 05:08 PM
permission or ownership problems trusouthrnplaya Linux - General 6 03-03-2002 04:33 PM


All times are GMT -5. The time now is 11:15 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration