How to copy a folder from remote using remote user with sudo? None of these works on folders with permissions and fails with permission denied:
scp -r userwithsudo@XX.XX.XX.XX:/source/ /destination/
sudo scp -r userwithsudo@XX.XX.XX.XX:/source/ /destination/
When I ssh on remote and perform sudo su
then I can view those files and folders. For me it doesn't matter to use scp
or smth else as long as it's ssh based.
Maybe it's a limitation of scp
to use sudo rights as security benefit. However it's really frustrating to be able to ssh, perform sudo su
and view all the folders, however not be able to download from remote (though you can probably workaround that with tar
and download anyway)
ssh
to the remote host, then there, doing asudo scp
back to where you are isn't an option? – infixed Mar 25 '16 at 10:58sudo
on your local machine does not give you root access on a remote machine. your 2nd commandsudo scp ...
runs the localscp
command as root, but the args tell it to connect asuserwithsudo
on the remote machine. That user may havesudo
privs to some or all commands but only when they actually runsudo
....andscp
has no way of doing that. The only way i can think of to do what you want is withrsync
's--rsync-path=PROGRAM
option to runsudo rsync
(perhaps with a wrapper script) as the remotersync
program. – cas Mar 25 '16 at 22:43