Wednesday, July 2, 2008

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

I really thought SCP always used the ownership of the user at the target
machine. That is, it always ignored the owner. Then again, on all of my
machines root is explicitly disallowed to log in via SSH.

When copying large numbers of files between machines, I usually use a
tar pipe:

sudo tar cf - SourceDir | ssh user@host 'sudo tar xf - -C /TargetBase'

Or (depending on quantity and available network/server bandwidth):

sudo tar jcf - SourceDir | ssh user@host 'sudo tar jxf - -C /TargetBase'

(The above activity may not work reliably unless sudo on the target host
is configured to not to always ask for the password and the password has
been provided to sudo within the timeout period.)

As far as I know, tar pipes are the standard reliable method of
performing this activity.

More frequently, though, I'm actually just making a backup and storing
it elsewhere (as the current machine doesn't have space to store it):

sudo tar jcf - SourceDir | ssh user@host 'cat > SourceDir.tar.bz2'

Or (depending on source machine's processing power):

sudo tar cf - SourceDir | ssh user@host 'bzip2 -c > SourceDir.tar.bz2'

Cheers,
Steven Black

On Wed, Jul 02, 2008 at 03:37:24PM +0000, 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.
>
> --
> Mark Krenz
> Bloomington Linux Users Group
> http://www.bloomingtonlinux.org/
> _______________________________________________
> 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: