What are the reasons that could make a change in a file ownership after
scp'ing it from one server to another?
The file ownership changed from 'owner' to 'apache'.
scp -p .
The user 'owner' exists on both servers and has the same UID.
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.Sign up to join this community
-p Preserves modification times, access times, and modes from the original file.
You can see the
-p option does not preserve ownership.
If you want to preserve file ownership, you can use
-g, which will preserve owner and group. This requires you to run
rsync as root.