DISCO
DISCO

Reputation: 357

How to copy directories under the root from the remote host?

I am trying to copy dirs and files under the root on the remote host, using non-root user, which one actually doesn`t have access to this folders. So I need something like sudo while copying.

Sample command:

scp user@<host>:<path_to_folder_under_the_root> .

I cannot use root@ cause I have not the root keys local. Is there any possible ways to do this?

Upvotes: 0

Views: 792

Answers (2)

DISCO
DISCO

Reputation: 357

The solution that works for me is rsync --rsync-path="sudo rsync".

Upvotes: 0

larsks
larsks

Reputation: 311606

Assuming that you do have sudo access on the remote host, instead of using scp you can use ssh and tar:

ssh user@<host> sudo tar -C <path_to_folder_under_the_root> -cf . | tar -xf-

Upvotes: 1

Related Questions