How can I secure connections between linux/unix rsync clients and cwRsync servers ?

Assuming that you want to synchronize directory /home/user on machine X_RSYNC_CLIENT with directory c:\backup on machine CWRSYNC_SERVER :

On CWRSYNC_SERVER :

- Install cwRsync Server with openssh component
- Start RsyncServer and OpenSSHD services
- Use Prep a Dir for Upload wizard for the directory c:\backup
- Add a new module to rsyncd.conf :

    [backup]
    path = /cygdrive/c/backup
    read only = false
    transfer logging = yes

on X_RSYNC_CLIENT :

- Copy private key from CWRSYNC_SERVER to X_RSYNC_CLIENT and make it accessible only by you
- Use shell script below after having it updated according to your needs:

    #!/bin/bash
    # Secure Channel Wrapper for connection to cwRsync servers from Linux/Unix clients
    # v1.0 - Initial version, Sep 2005, Tevfik K., http://itefix.no

    # Customize variables below according to your needs

    # identity: private key file for cwRsyncServer service account (available from Start Menu)
    identity='cwrsync'

    # localport: local port for forwarding
    localport=9119

    # remoteport: termination port (this should be the port rsync daemon listens to)
    remoteport=873

    # remotehost: cwRsync Server name/ip-adress
    remotehost=192.168.2.26

    # your rsync module at server side
    rsyncmodule=backup

    # Function to terminate secure tunnel processes
    TerminateTunnel ()
    {
    ps ax | grep "ssh -i $identity -L $localport" | awk '{print $1}' | xargs -i kill {} 2&>/dev/null
    }

    # Clean up ... terminate zombie tunnels
    TerminateTunnel

    echo Establishing secure channel ...
    ssh -i $identity -L $localport:127.0.0.1:$remoteport SvcwRsync@$remotehost -T -N -f

    # your rsync command, you can edit:
    # - rsync options (-av)
    # - source files (temp/)
    # - exchange source and destination
    # - and more :-) Try and tell me!
    rsync -av temp/ rsync://SvcwRsync@localhost:$localport/$rsyncmodule

    echo Terminating secure channel ...
    TerminateTunnel

NB! You must forward ssh port 22 to CWRSYNC_SERVER at the edge of your secure network (your router/firewall). I recommend strongly to tighten security further by using options available in rsync and openssh (host limitations, secrets file ...).

Who's online

There are currently 0 users and 6 guests online.

Site statistics

Registered users2537
Posts1902
Comments4925