Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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'. I used scp -p . The user 'owner' exists on both servers and has the same UID.

share|improve this question

From man scp:

-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 rsync with -o and -g, which will preserve owner and group. This requires you to run rsync as root.

share|improve this answer

When you scp, the ownership comes from the user you use to scp to the other machine. For example:-


The ownership of FILENAME at the host HOSTNAME after scp will be USER as owner and primary group of USER as its group ownership.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.