I have 2 Ubuntu servers: 12.04.5 LTS and 16.04.1 LTS, in a local network, where I'm a administrator of the both servers and can be the super users on them. Let's say each server is A and B, and I log in to the server A now.
When I want to copy a file from A to a directory in B, where root authority of B is required to put the file, how can I do that?
My trial was as follows but it didn't work due to no authority for the server B:
sudo scp /foobar/foo/bar.txt user@serverB:/bar.txt
scp: /bar.txt: Permission denied
The sudo power affects only the permission of the source and doesn't affect the permission of the destination directory.
Of course, If I change the permission of the destination directory appropriately, I can copy the file without no permission error. But changing the permission every time when I copy files is a little annoying.
And root login is not allowed to both servers as the default configuration of Ubuntu is so.
If any of you know some good way, please teach me. I use bash shell.
drwxr-xr-x 25 root root 4096
. – Taiki Bessho Jan 25 '17 at 11:29