Re: copy server to server retaining chmod and ownership?

news_at_celticbear.com
Date: 11/14/05


Date: 14 Nov 2005 12:03:10 -0800


Peter T. Breuer wrote:
> news@celticbear.com <news@celticbear.com> wrote:
> > I have 32GB of files and directories to copy from one server to
> > another.
> > But when I use scp it converts all the ownership to the user I scp'ed
> > through.
>
> What would you expect? That user cannot create files belonging to a
> different user! You must at least be root if you expect to be able to
> do that.
>
> And what does scp do when you use -p (as root)?
>
Thanks for the reply.
Yes, that makes perfect sense. And unfortunately that may be the point
at which none of this will work. sshd_config is set to not allow root
to ssh. Security measure.
I suppose to could change it to allow root logon just for this, if
that's the only way around it.
I realize that without using root, there's no way to maintain ownership
and group settings.

>
> -p Preserves modification times, access times, and modes
> from the original file.
>
> Come to that, what happens when you use rsync -e ssh (as root)?
>

Yeah, I saw the -p in the tar man and tried it before I posted...and of
course because I'm using scp as non-root, it kept the permissions, but
set the ownership of the destination files to the user it's scp'ing
through.
Funny thing, I had guessed that was likely the case, not being root,
that prevented the ownership retention, yet, because it did copy files
over owned by root:root, I thought maybe there was a way to bypass the
problem.

rsync, interesting. The man for scp mentioned rcp, but with no man on
the server for rcp, I didn't know about rsync. Looks very useful!!
Again though, with root ssh login disabled, permission denied.
For just this server migration, since it looks like the only way to
copy 30GB over and keep all ownership has to be done through root, I'll
be reenablin the root ssh login.

> > I can't tarball the stuff
>
> Of course you can - you can tar it to stdout.
>
Didn't know that was an option. Looked at the man, and the reference to
stdout didn't indicate any hint at transferring to a remote server.
However, I figured this much out:

tar -czvf - foo | ssh (remoteserver) 'cd /foo/bar; tar -xzf -'

I tried with and without the --same-owner option, and still it converts
ownership to the user the ssh is going through.

I also tried, as root:

tar -czvf - ./* | ssh -l liam (remote server) 'cd /home/liam; tar -xzvf
-'
(with and without --same-owner)
Thinking the tar process would keep ownership but I can still bypass
the disabled root ssh login, but it still changed all ownership:group
to "liam" through which it was ssh'd.

> > because I only have 3GB left on the source
>
> Invalid reason.
>
> > What other options can I look into to copying that much data over, and
> > allowing it to keep owners and permissions?
>
> Use tar. This is standard stuff!
>
> Peter

Well, I'm going to read more about tar, but if I'm not mistaken,
there's likely no way around the ownership conversion if root isn't
being used for the ssh login. If I can't find any new info, way around,
I'll just enable root ssh login do it that way.
Thanks for the advice.
Liam



Relevant Pages

  • Re: FC2 granting rw on FAT32 dir [solved]
    ... James Wilkinson wrote: ... > Duncan Lithgow wrote: ... > ownership on FAT32: Windows pretends there is, sometimes, but there's ... > nothing for root or anyone to change on the disk. ...
    (Fedora)
  • Re: new to ubuntu; have a few questions
    ... the file system has an unknown owner; how do i put the root as owner ... i tried <chown root /> and root did not take ownership. ...
    (Ubuntu)
  • Re: Excellent news.. Malware for OS X!
    ... It stems from what the processes ownership and rights are. ... The Permissions can get a bit sticky on the system side. ... If you'll note that some files ownerships are 'root' 'wheel' and then ...
    (comp.sys.mac.advocacy)
  • Re: What the logic to group ownership?
    ... >what difference does it makes if the group is root, bin, sys, other ... The group ownership is largely ... >which have a group of uucp, but since the permissions are still 555, ...
    (comp.unix.solaris)
  • Re: One more try...lost permissions on drives
    ... Currently I can read and write to them as root, ... No "magic bullet" to take ownership of the drives, ... If America weren't incomparably ignorant, ...
    (alt.os.linux.suse)