Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Possible duplicate of scp to remote server with sudo

I'm facing the following issue:

  • A folder (with sub-folders) with files belonging to usr1:usr1
  • I login with another user usr2
  • usr2 can do sudo -u usr1
  • How can I copy the whole folder to another Linux box over ssh?

I tried the following with no success:

sudo -u usr1 tar cf - * |  ssh  usr2@host 'cd /tmp/dump;  sudo -u usr1 tar xf -'

Any help would be appreciated

share|improve this question
add comment

2 Answers 2

On the host containing the folder to be copied, run this:

sudo -u usr1 scp -r folder-to-copy usr2@host:/tmp/dump/.
share|improve this answer
add comment

You can do this using scp as mentioned in the link you provided, but with the -r flag added to the command. The -r means recursive, so it repeats the scp command for every file and/or folder it finds in that particular folder.

scp -r yourfolder name@host:targetfolder

share|improve this answer
    
it won't work because of permission. virtually -1 to you ) –  ravnur May 24 '13 at 15:09
add comment

Your Answer

 
discard

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.