Find Log of Rsync Command Run on Remote Machine – How to Guide

loggingrsync

I'm running rsync via ssh to a remote machine. After running the command, I'd like to confirm that the command I sent to the remote machine is the one that actually ran. Is this logged somewhere? The remote machine is a debian box.

Best Answer

Just to be clear, using rsync/rsyncd may be different to this; you're running rsync -> ssh -> sshd -> rsync, so rsyncd is not involved.

By default, rsync does not log what it's doing. If you want to know historically what has been executed in the past, it's possible that sshd may have logged the commands it was given by rsync, but unlikely.

If you just want to know what the command is, run rsync manually, and specify "rsh='ssh -v'" to enable verbose output, and watch for "debug1: Sending command: rsync --server ...".

You can set things up to force logging for the command, by adding this:

command="logger -p user.notice $SSH_ORIGINAL_COMMAND; $SSH_ORIGINAL_COMMAND" ssh-rsa AAAAB3NabcdABCD... rsa-key-bla

to the authorized_keys file, against the key used for logging in. You may want to create a key just for rsync.

Actually, forcing a command causes a log to be written of the command. So that might be all you need.