debian rsyncd 安裝


rsync is a great tool for synchronizing 2 directories (or files) either one of them is remote and the other is local, or 2 local folders (it doesn’t support synchronizing 2 remote servers, yet). the power of rsync comes from that it doesn’t transfer anything unless it detects that it’s changes since last run. moreover, it transfer the changes in files only (unless you specified otherwise), and it can even compress files before sending which makes it ideal for continuous backups and mirroring.

to use rsync, you have 2 options. either to start rsync daemon which handles the connections, or use it through ssh tunnel. each way has its positives and negatives. rsync daemon is indeed faster in intiating connections cause it doesn’t exchange keys or encrypt data, which makes its load on the server is less too. the overhead of keeping the daemon alive is so small that you can simply ignore. the ssh tunnel doesn’t require a special configuration on the server side, but you must have ssh access to the server, which means that you can’t grant anonymouse access to your data. the main positive of ssh tunnel is that data is sent through the secure tunnel and can’t be sniffed.

  1. to connect through ssh tunnel: first, you’ll need to install rsync:
    apt-get install rsync
    then you are ready, just issue the command directly
    rsync -avz -e ssh remoteuser@remotehost:/remote/dir /this/dir/
    remember to check the permissions for ssh user on the remote server. (the remote server must have rsync installed too).
  2. to connect through rsync server:
    1. install rsync:
      apt-get install rsync
    2. create “/etc/rsyncd.conf” and put the following in it:
      max connections = 1
      log file = /var/log/rsync.log
      timeout = 300
      comment = Cache of Mongrels
      path = /usr/local/cache
      read only = no
      list = yes
      uid = nobody
      gid = nogroup
      #auth users = mongrel
      list = yes
      hosts allow =
      #secrets file = /etc/rsyncd.secrets

      note that the first few lines are global (for all modules) and the other one is specital for the public module.
      comment the last two lines to grant anonymouse access, note that you can still limit by ip/netmask

    3. create ”/etc/rsyncd.secret”, and put the usernames and passwords for the ones who can access rsync, in the form of username:password , note that passwords are saved here as clear text. so don’t forget to chmod it to 400 to keep the passwords somehow safe
    4. make rsync to start as daemon:
      edit ”/etc/inetd.conf” and put the following line in the end:
      rsync stream tcp nowait root /usr/bin/rsync rsync –daemon
    5. voila, you are done, test your settings by typing:
      rsync rsync://your_ip_or_domain_name/
      this should list the modules
      rsync rsync://your_ip_or_domain_name/public
      this shuold list the files in your ‘public’ modules
      rsync -avz rsync://your_ip_or_domain_name/public
      synchronozing should start the transfer now.
      don’t forget to check the rsync man page to check what flags do you really need.


發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *