LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   [SOLVED] initiating a reverse rsync (https://www.linuxquestions.org/questions/linux-software-2/%5Bsolved%5D-initiating-a-reverse-rsync-942484/)

eco 04-30-2012 01:11 AM

[SOLVED] initiating a reverse rsync
 
Hi all,

What I am trying to do is have server "A" ask server "B" to send files to server "A". So Server "A" should initiate an rsync request to have files from server "B" sent to itself.

The reason for this is that a few servers use rsync to backup their files to server "B" along with proper permissions, etc. To avoid connecting from server "A" to the server "B" as root , I need to ask server "B" to rsync the files to server "A".

I think this can be done with rsync-path but if it can... I haven't figured out how. ;)

Any advice help... or clarifications requests are welcome. :)

eco 04-30-2012 02:34 AM

It's good to have your own Guru at work ;)

The following is the solution for anyone wanting to do this. No credits to me, all to the anonymous Guru!

Add your key to avoid being prompted by a password
Code:

serverA $ ssh-add
Find out what socket you are using
Code:

serverA $ echo $SSH_AUTH_SOCK
/tmp/ssh-XHGFQ10086/agent.10086

Become root and define your user socket as the one for root
Code:

serverA $ sudo su -
serverA # export SSH_AUTH_SOCK="/tmp/ssh-XHGFQ10086/agent.10086"

Now when you ssh from root as your user, you can do so without password
Code:

serverA # ssh mysuer@serverB
Last login: Thu Apr 26 14:29:53 2012 from 10.100.1.10
serverB:~ $ logout
Connection to serverB closed.

Now, using our socket again, we initiate an rsync as root using the rsync-path to tell serverB it will also be running rsync as root although we connect as our user.
Code:

serverA # rsync -avn --rsync-path="sudo rsync" mysuer@serverB:/root/ /tmp/
receiving incremental file list
./
.Xauthority
.bash_history
.exrc
[...]
sent 139 bytes  received 1062 bytes  2402.00 bytes/sec
total size is 69933054  speedup is 58229.02 (DRY RUN)

Voila! We managed to tell rsync to sync the /root folder from serverB to serverA without having to ssh as root. Cooool.


All times are GMT -5. The time now is 08:14 AM.