Use Rsync Daemon with SSH !? [ solved ]
from Donatello@lemmy.ml to linux@lemmy.ml on 24 Nov 12:15
https://lemmy.ml/post/22845490

Hi,

I need to setup a Rsync server to backup a šŸ˜” NAS.

So I want to run it under SSH.

man rsync

> Also note that the rsync daemon protocol does not currently provide any encryption of the data that is transferred over the connection. Only authentication is provided. Use ssh as the transport if you want encryption.

but when I do rsync --config=/etc/rsyncd.conf --rsh=ssh --dry-run
I get:

rsync: --rsh=ssh: unknown option (in daemon mode) So there no way to specify that rsync daemon should run under ssh ?

Also is this following A.I statement is correct ?

The rsyncd.conf file is only used when the rsync daemon is running on the remote host and the client connects to the daemon directly, without using an SSH connection.

So there is no way with Rsync (under ssh) to set settings (config file or other) that will apply to all clients !!??
So itā€™s the client that configure rsync and the server !? there is no way around ?!

#linux

threaded - newest

tenchiken@lemmy.dbzer0.com on 24 Nov 12:36 next collapse

Soā€¦ As long as you have ssh running open on the receiving server, you donā€™t need the rsync daemon. Rsync client will ssh, then execute rsync recipient automatically.

The daemon is only for if you donā€™t want to or cannot run ssh really.

Is there a specific reason you are looking at the daemon, or just unfamiliar?

HauntingScience@programming.dev on 24 Nov 13:08 collapse

Using the daemon also allows you to transfer faster by removing compression and encryption. It tends to hit the same rclone speeds without the data corruption issues.

tenchiken@lemmy.dbzer0.com on 24 Nov 20:56 collapse

You can do so directly in the ssh config or command line also. Iā€™ve used this very thing in dense cluster private OpenStack deployments over the years.

Just trying to narrow down use case but I suspect the complex documentation just overwhelmed.

cypherpunks@lemmy.ml on 24 Nov 23:22 next collapse

(disclaimer: this information might be years out of date but i think it is still accurate?)

SSH doesnā€™t have a null cipher, and if it did, using it still wouldnā€™t make an SSH tunnel as fast as a TCP connection because SSH has its own windowing mechanism which is actually what is slowing you down. Doing the cryptography at line speed should not be a problem on a modern CPU.

Even though SSH tunnels on your LAN are probably faster than your internet connection (albeit slower than LAN TCP connections), SSHā€™s windowing overhead will also make for slower internet connections (vs rsync or something else over TCP) due to more latency exacerbating the problem. (Whenever the window is full, it is sitting there not transmitting anythingā€¦)

So, to answer OPā€™s question:

  • if you want to rsync over SSH, you usually donā€™t need a daemon (or to specify ā€“rsh=ssh as that is the default).
  • if you the reason you want to use the rsync daemon is performance, then you donā€™t want to use SSH. youā€™ll need to open a port for it.
  • besides performance, there are also some rsync features which are only available in ā€œdaemon modeā€. if you want to use those, you have at least 3 options:
    • open a port for your rsync daemon, and donā€™t use SSH (bonus: you also get the performance benefit. downside, no encryption.)
    • setup an SSH tunnel and tell the rsync client it is connecting to a daemon on localhost
    • look at man rsync and read the section referred to by this:
      • The remote-shell transport is used whenever the source or destination path contains a single colon (:) separator after a host specification. Contacting an rsync daemon directly happens when the source or destination path contains a double colon (::) separator after a host specification, OR when an rsync:// URL is specified (see also the USING RSYNC-DAEMON FEATURES VIA A REMOTE-SHELL CONNECTION section for an exception to this latter rule).

HTH.

drwho@beehaw.org on 25 Nov 17:12 collapse

Iā€™ve been doing the same in pull-backups for years. It works nicely.

ReversalHatchery@beehaw.org on 24 Nov 16:03 next collapse

I think you donā€™t need to specify that you want to use SSH. unless you give the location as starting with rsync://, or set to use the rsh protocol, it should use ssh by default.
just use user@targethost:path. The part before : is the same as what you use in SSH, and the part after it may be an absolute or a relative (to user home) path

IsoKiero@sopuli.xyz on 24 Nov 16:04 next collapse

The statement is correct, rsync by itself doesnā€™t use ssh if you run it as an daemon and if you trigger rsync over ssh then it doesnā€™t use daemon but instead starts rsync with UID of the ssh-user.

But, you can run rsyncd and bind it only to localhost and connect to that over ssh-tunnel. That way you can get benefits of rsync daemon and still have encrypted connection with ssh.

Donatello@lemmy.ml on 25 Nov 06:42 collapse

Thank you @IsoKiero@sopuli.xyz !
This is the solution.

unfortunately I canā€™t apply it, because the NAS is a closed proprietary šŸ’©

matcha_addict@lemy.lol on 24 Nov 16:27 next collapse

So there is no way with Rsync (under ssh) to set settings (config file or other) that will apply to all clients !!??
So itā€™s the client that configure rsync and the server !? there is no way around ?!

You basically want to use the daemon but under ssh. I looked into this before, and I think it is possible but the command for it is weird and confusing. Wish I remembered it, but just commenting to say that I vaguely remember thereā€™s a way (or maybe Iā€™m hallucinating).

fredrik@lemmy.world on 25 Nov 08:57 next collapse

stackoverflow.com/ā€¦/copying-files-using-rsync-froā€¦

Hereā€™s several ways to run rsync over SSH.

PseudoSpock@lemmy.dbzer0.com on 25 Nov 19:22 collapse

Given that you can already use rsync over ssh, I suspect you want to allow the rsync configuation options on the server side, but still use ssh to secure the transit. I would do it like this:

  • Configure rsync on receiving server to listen only on 127.0.0.1 (localhost).
  • Use ssh to create a tunneled port between your sender and receiving rsync server.
  • Rsync on the sender to [rsync defined user@]localhost:port (whichever port you set the tunnel up on) as your target.

That would encrypt the traffic over your ssh tunnel, but still allow you to use the receiverā€™s rsyncd paths.