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)
sshto the remote host, then there, doing asudo scpback to where you are isn't an option? – infixed Mar 25 '16 at 10:58sudoon your local machine does not give you root access on a remote machine. your 2nd commandsudo scp ...runs the localscpcommand as root, but the args tell it to connect asuserwithsudoon the remote machine. That user may havesudoprivs to some or all commands but only when they actually runsudo....andscphas no way of doing that. The only way i can think of to do what you want is withrsync's--rsync-path=PROGRAMoption to runsudo rsync(perhaps with a wrapper script) as the remotersyncprogram. – cas Mar 25 '16 at 22:43