1753899 Members
7871 Online
108809 Solutions
New Discussion юеВ

Remote copy

 
SOLVED
Go to solution
O'lnes
Regular Advisor

Remote copy

How can i copy file to remote hosts and preserve the owner UNchanged? Thx.

Andy
9 REPLIES 9
O'lnes
Regular Advisor

Re: Remote copy

i tried 'rcp -p' is not work.
can suggest other method?
Andy
T G Manikandan
Honored Contributor

Re: Remote copy

check for the -p option of rcp.

-p preserve permissions

rcp -rp :path


Thanks
David Lodge
Trusted Contributor

Re: Remote copy

The owner of the received file will always be the owner you rcp *to*.

This is the only way it can work...

eg

$ whoami
alice
$ rcp foo wibble:/home/alice/.
$ rcp bar wibble:/home/alice/. -l bob
$ ssh alice@wibble
$ ll -l foo
... alice ...
$ ll -l bar
... bob ...
$ exit

dave
Andreas Voss
Honored Contributor

Re: Remote copy

Hi,

do it with this:

echo FILE |cpio -ocB|remsh HOST "cd PATH;cpio -imdvcB"

Replace:
FILE=filename to copy
HOST=destination host name
PATH=destination full path

Regards
T G Manikandan
Honored Contributor

Re: Remote copy

rcp -p will preserve permissions.

After doing a rcp do a ls -l

it will have the same uid and gid of the old machine.


I think you have misunderstood.

1.If the uid and gid of the rcp-ied file matches the local machine uid and gid it will display that owner on the local machine.
2.if the uid and gid does not match any user or group in the /etc/passwd and /etc/group file when you do a ls -l it will only display the uid and gid.


o'lines
you have a very poor point assignment average.
Hope you improve your average.

Thanks

Elif Gius
Valued Contributor
Solution

Re: Remote copy

You can use :
rcp -p or
scp -p

If the uid and gid of the file you copied matches to the uid and gid on the remote machine -it will display the owner

If the uid and gid is not identical to any user in the /etc/passwd it will only display the uid/gid of the file when you do 'ls -la'.

+++ If uid 210 belongs to user oracle on machineA, and on machineB uid210 belongs to user operator, the file owner on the remote machine will be user operator +++
That's why it is useful to keep uids/gids identical on different systems.
Ken Hubnik_2
Honored Contributor

Re: Remote copy

After you do a rcp you can do a rcmd to change the permissions to whatever you want them to be.
Christian Schulze
Regular Advisor

Re: Remote copy

Hi,

you might try this too

tar -cf - *.gz | remsh snoopy "(cd /otherdirectory ; tar -xf - )"

where snoopy is the destination host


But the UID and GUIDs of both systems have to be identical as already mentioned ...

Christian
never touch a running system
Govind
Frequent Advisor

Re: Remote copy

Assuming you the end host is in the ~/.rhosts file on the first host. You could try the following command on the end host
rsh first_host 'cd DIRECTORY_YOU_THE FILES_IN;tar cvfp - FILE_NAMES'|tar xvfp -

This definitely works since I use it very often. As others pointed the UIDS and the GIDS should exist on both machines for the username to appear when you do a "ls -l". What I also found was, interstingly you cannot retain the sticky bit on the files if it is root owned unless you have root access on the destination machine.
Regards
Govind
Dont try to fix something till it Aint Broke...Honesty is not always the best policy.....