Some context:
- I have some services running on my Debian server, and from time to time I want to make a backup of the relevant data
- I have a
backup
directory on the server, which I update manually by stopping the services, copying the data into that directory (usingrsync -Payz --delete --recursive
, which preserves metadata and avoids unnecessary copies), then relaunching the services - I want to have a copy of the
backup
directory on my laptop, and keep it updated - To that end, I want to run something like
rsync -Payz --delete --recursive user@server:backup .
- The main difficulty here is that many of the files have
root
as an owner andrsync
isn't allowed to move them withoutsudo
(the services run in containers, and those permissions make sense at the container level, but at the host level the system considers the host'sroot
is the owner) - To create the sever backup I can simply call
sudo rsync
, but for the copy on my laptop I have to tellrsync
to runsudo rsync
on the server and forward the password request to the client, which brings us to the current issue
What I've done:
I've followed the advice from this post, so the full command I'm running is
rsync -Payz --delete --recursive -e "ssh -X" --rsync-path="sudo -A rsync" user@server:backup .
--rsync-path="sudo rsync"
is used to runrsync
withsudo
rights on the remote--rsync-path="sudo -A rsync"
is used so thatsudo
relies onssh-askpass
to get the password-e "ssh -X"
enables X11-Forwarding so thatssh-askpass
can ask me to type the password on my laptop
The issue
- This used to on my old laptop (a MacBook), but doesn't on my new one (running a Manjaro distribution). Given that the linked post's comments say it's working on Ubuntu, I'm assuming I need to change something in my configuration, or maybe I'm missing a dependency or something, but I have no idea what or why
- The error I get is the following:
Error: Can't open display:
sudo: no password was provided
sudo: a password is required
rsync: connection unexpectedly closed (0 bytes received so far) [Receiver]
rsync error: error in rsync protocol data stream (code 12) at io.c(231) [Receiver=3.2.7]
- When I run the command with
-e "ssh -Xv"
, the following lines appear that seem to be the issue
debug1: X11 forwarding requested but DISPLAY not set
debug1: Sending command: sudo -A rsync --server --sender -logDtprze.iLsfxCIvu . backup
Error: Can't open display:
sudo: no password was provided
sudo: a password is required
debug1: client_input_channel_req: channel 0 rtype exit-status reply 0
debug1: client_input_channel_req: channel 0 rtype eow@openssh.com reply 0
debug1: channel 0: free: client-session, nchannels 1
rsync: connection unexpectedly closed (0 bytes received so far) [Receiver]
Transferred: sent 2176, received 2464 bytes, in 0.2 seconds
Bytes per second: sent 9432.6, received 10681.1
rsync error: error in rsync protocol data stream (code 12) at io.c(231) [Receiver=3.2.7]
so apparently when rsync
runs ssh -X
here, the DISPLAY
variable is left unset
- If I run
ssh -X 'echo $DISPLAY
however, it does displayslocalhost:10.0
, and runningssh -X user@server 'sudo ls'
does ask me the password as expected (through a window titled "OpenSSH Authentification Passhrase Request") - I believe that means that the problem is in the interaction between
ssh -X
andrsync
, not the X11-Forwarding itself, but I don't get what I'm doing wrong