Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

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

scp with password less authentication is working fine but if delete a file on the source it will not get replicated ie the destination directory is not completely replaced with source. I can see the new files or modifications are properly get replicated.

scp -r /user/local/img root@
share|improve this question
up vote 5 down vote accepted

scp is only a copy tool, so if you have to use scp, your only real choice is to empty the destination directory tree first.

Alternatively, you should probably look into using rsync, this will run over ssh using the passwordless setup you have now, and has many advantages (it can replicate deletes, only transfers changed data so copies are quicker, and can compress data during transfer). If you change your command to this one, you should get the results that you want (although test it first to make 100% sure it does what you're looking for!):

rsync -avz --del /user/local/img root@

share|improve this answer

scp works much like standard cp - it copies what you tell it to copy. Your command above says that it should copy the local folder /usr/local/img to /usr/local/img on the remote server; if the remote folder already exists, then it'll copy to /usr/local/img/img.

share|improve this answer

scp is much the same as cp it doesn't delete destination files if the source has been deleted . If you want to keep source and destination directories in sync then rsync is the way forward.

rsync -avz --delete /user/local/img root@

you can also use rsync over ssh

rsync -avz -e ssh --delete /user/local/img root@
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.