Sat, 15 Jan 2005
trivial but useful hack for redirecting rsync through a firewallrsync is an excellent tool for replicating directory trees on a drive or across a network. You can specify the transport layer for network copies, it defaulting to use ssh. The below script just pipelines two sshs together cleanly to use as a the transport, to replicate a directory tree to/from a server inside a firewall:
example command line from outside the firewall:
ENDHOST=192.168.1.20 rsync --delete -vzaP --rsh ./dssh.sh firewall.example.org:/backups/ /backup/fubar/In this case ENDHOST is set to the IP address of the endpoint host inside the firewall, while firewall.example.org is the hostname of the firewall we have ssh access to to get to the firewall.
dssh.sh consists of the following
#!/bin/bash # simple ssh wrapper so we can treat 2 sshs pipelining as one.. MIDHOST=$1 shift 1 exec ssh $MIDHOST ssh $ENDHOST $*Nice and simple, and saves a lot of messing about with port forwarding, escaping of command line args etc.