Your server is not sshing to $S and $DS, your server is only sshing to $S and then telling $S to ssh to $DS. $S needs to be able to ssh into $DS without a password if you want it to work as written.
I do not believe rsync will allow you to sync between two remote systems without a direct ssh connection between them. You'll either need to set up ssh keys between your source and destination servers and use your code as-written, or do the sync in two steps using your centralized server as a neutral 3rd party:
rsync -av root@$S:/dir $S/dir
rsync -av $S/dir root@$DS:/dir
Last edited by suicidaleggroll; 04-28-2015 at 12:17 PM.