3

I want to upload files using rsync over SSH.

On server side I have:

In /root/.ssh/rsync.conf:

uid = root
gid = root
use chroot = false

[data]
    path = /var/www/data

In /root/.ssh/authorized_keys I have:

command="rsync --server --daemon --config rsync.conf ." ssh-rsa AAAAB3N...

On client side I have ssh_config file such as:

Host rsync_data
  User root
  IdentitiesOnly yes
  IdentityFile /home/me/.ssh/id_rsa_rsync
  ProxyCommand ssh eu -W 172.17.16.16:22
 
Host eu
 User me
 Port 4343
 Hostname My_Public_IP_Address_here
 IdentitiesOnly yes
 IdentityFile /home/me/.ssh/id_rsa_rsync

Finally, command getting launched is:

rsync \
 --delete \
 -avz \
 --stats \
 --progress \
 -e 'ssh -F /home/me/.ssh/config' \
 /home/me/Documents/dev/data/ rsync_data::data

SSH connection goes well as read in /var/log/auth.log but I get this rsync error:

rsync error: syntax or usage error (code 1) at clientserver.c(1223 [Receiver=3.2.3]
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]

How can I solve the issue I am encountering?

3
  • 2
    Why did you configure anything with /root/.ssh/authorized_keys or /root/.ssh/rsync.conf? Whenever I do Rsync the most I have to do is just add id_rsa.pub and then just do a plain Rsync without something like what you have here: -e 'ssh -F /home/me/.ssh/config'. My initial thoughts is you are making this more complex than need be. Dec 28, 2022 at 17:49
  • 1
    I want to contrain client to only upload into a specific folder enforced by server in rsync.conf`. Is there another way to do it ? Also if i only add SSH keys into /root/.ssh/authorized_keys`` then anyone having access to client can directly get shell on server (as root!) where with this configuration, all an attacker can do is uploading wrong content that may be easier to dissmiss
    – philippe
    Dec 28, 2022 at 21:35
  • 1
    Look up chroot jails. Look at this thread on the Unix Stack Exchange site that explains them. But also realize that you might overthinking this all. Why not set up a non pro ledges user on the destination server to SSH/Rsync content to and use that user for file transmission. Remember the root user n the destination server can access any file from any user. Why risk anything by using root to transmit files? Create a new user, allow that user limited access to the destination directory and that’s that. Dec 29, 2022 at 2:27

1 Answer 1

3

Finally I got it.

Only thing I was missing is that daemon is looking for rsync.conf in user home directory or in /etc/rsync.conf if user is root.

This answer on Server Fault made my day : solution.

1
  • Cool! Just one relatively small suggestion: Using one backtick (`) is good for inline code and three backticks (```) are good for code blocks, but you seem to be consistently setting two backticks (``) which do nothing special at best or break formatting at worst. Look at how your comment here is broken due to that. Please just use one backtick (`) for inline code formatting. Dec 29, 2022 at 21:41

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .