I want rsync with sudo.
1 I try solution from this topic:
huser@linux:~$ rsync -avz --stats --rsync-path="echo 4321 | sudo -Sv && sudo rsync" /home/huser/mylibs/ ruser@192.168.0.100:/home/ruser
ruser@192.168.0.100's password:
I am confused - rsync shouldn't ask for a password, should it? Ok, I type ruser's password and get error:
[sudo] password for ruser: sudo: a terminal is required to read the password; either use the -S option to read from standard input or configure an askpass helper
sudo: a password is required
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: error in rsync protocol data stream (code 12) at io.c(231) [sender=3.2.7]
Where
ruser is my username in remote Ubuntu 22,
huser is my username in host Ubuntu 22,
4321 is ruser's password (for me ok to keep it in history),
192.168.0.100 is remote machine IP.
2 I try another way, I have ssh key:
rsync --rsync-path="sudo -S rsync" -rvz -e "ssh -i /home/huser/key/my_ssh_key" --progress /home/huser/bin/ ruser@192.168.0.100:/home/ruser/
[sudo] password for ruser: 4321
And I wait a while for a folder of several bytes to transfer... but nothing happens, not even an error.
3 Let's check that rsync can work without sudo:
rsync -avz --stats /home/huser/mylibs/ ruser@192.168.0.100:/home/ruser
This works ok.
How I can work with sudo?