Wednesday, July 2, 2008

Re: [BLUG] scp -p preserving ownership through root user

I have to correct myself since my explanation was wrong.

> scp -p files root@machineB:

In this case, you log into machine B as root and then create the 'files.'
Thus it will be owned by root. But if you do

scp -p files user@machineB:

it login as 'user' and create the file; thus owned by user (and the file
is right under user's home directory.)

Shing-Shong


> This is because the files on machine A is created by root, the user who
> is running the scp. If you want to preserve all information, you need
> to use tar:
>
> ssh machineB -n tar cCf /path/to/file - . | tar xf -
>
> (Or you have to 'su X' on machine A before you do the scp.)
>
> Shing-Shong
>
> Mark Krenz wrote:
>> I have some files that are owned on machine A by user X. As the root
>> user on machine A, I run
>>
>> scp -p files root@machineB
>>
>> The mode and modification times are preserved, but the ownership is
>> not. I know that with rsync -a the ownership is preserved, but
>> according ot the scp man page, ownership isn't preserved with -p. I
>> just got burned by this. Tell me if I'm insane or not but I could swear
>> that this worked before. It might have had this in a much older version
>> of scp, like the old non-openssh version of ssh.
>>
>> Know your options.
>>
>>
> _______________________________________________
> BLUG mailing list
> BLUG@linuxfan.com
> http://mailman.cs.indiana.edu/mailman/listinfo/blug
_______________________________________________
BLUG mailing list
BLUG@linuxfan.com
http://mailman.cs.indiana.edu/mailman/listinfo/blug

No comments: