Home > Linux > Set Up An rsync Server in Ubuntu for File Syncing Between Machines

Set Up An rsync Server in Ubuntu for File Syncing Between Machines

I’ve been doing some programming on my laptop recently and then finding myself without my work when I’m on my desktop.  I remembered someone telling me that they use rsync to keep their source directories in-sync between their home and work machines, so I figured I’d do the same.

I thought it would be trivial to accomplish a file transfer using rsync between 2 machines on a local network, but I ended up spending an hour more than I wanted to.

So, first of all you need to have rsync on both machines (the server and the client).  In my situation, I’m running Ubuntu 8.04 LTS on my desktop and Windows XP w/ Cygwin on my laptop; rsync comes pre-installed in Ubuntu and as an install option in Cygwin.

If you’ve already got Cygwin but rsync is not installed, you need to run the Cygwin setup.exe again. Then, rsync will be under the Net directory in the package choosing menu.

On the server machine you need to set up a daemon to run in the background and host the rsync services. First – before you start the daemon – you need to create an rsync daemon configuration file. To do this in Ubuntu, create a file named rsyncd.conf in the /etc directory, i.e.

you@your-computer:~$ sudo gedit /etc/rsyncd.conf

Now enter the following information into the rsyncd.conf file:

motd file = /etc/rsyncd.motd

path = /home/username/workspace
comment = This is the path to my Eclipse workspace (on the server)
uid = username
gid = username
read only = false
auth users = username
secrets file = /etc/rsyncd.scrt

Now replace all occurrences of username with your username on your server (not the username on your client machine!). Since I set this up for keeping my Eclipse workspaces in-sync, I used “workspace” for the path name, but you can use anything (so change “[workspace]” to “[whatever_you_want]“). I also set the path equal to my Eclipse workspace, but once again, this path can go anywhere you want to sync your files to.

Notice there are two other files mentioned: /etc/rsyncd.motd and /etc/rsyncd.scrt. You need to create these the same way you created the /etc/rsyncd.conf file.

The /etc/rsyncd.motd is the Message Of The Day file. The contents of this file will be displayed by the server when a client machine connects.

The /etc/rsyncd.scrt file contains username and password pairs. For example,


As before, username should be your username on your server.

Now you should have all the configuration information necessary, all that’s left to do is open the rsync port and start the daemon.

To open the port, open the /etc/default/rsync file, i.e.,

you@your-computer:~$ sudo gedit /etc/default/rsync

and set RSYNC_ENABLE=true.

Now to start the daemon,

you@your-computer:~$ sudo /etc/init.d/rsync restart

There you have it, your rsync server should be up and running!

Now you probably want to know how to copy files from your remote machine to your server. In Cygwin,

$ rsync -vr SRC username@server ip-address::workspace/DEST

The -vr flags are for verbose output and recursive (so entire directory structures can be copied). The SRC is the root directory of your source files. If you wanted to sync your entire Eclipse workspace with the workspace on your server, this would be the workspace directory; the recursive flag would then go through all the projects within your workspace directory and copy everything. The username should match the username in the /etc/rsyncd.conf file. The “workspace” after “::” should match your path name in the /etc/rsyncd.conf file, i.e., the “[workspace]“. DEST is then appended to the path from the /etc/rsyncd.conf file, i.e., /home/username/workspace/DEST.

When you enter this command you should see the contents of the /etc/rsyncd.motd file appear and you should be prompted for the password corresponding to the username provided. This username/password pair should match the contents of the /etc/rsyncd.scrt file. Once you enter the password correctly, the sync will begin!

Here’s an example with the username on the server “nick” and the server ip-address is “″:


motd file = /etc/rsyncd.motd

path = /home/nick/workspace
comment = My Eclipse workspace directory.
uid = nick
gid = nick
read only = false
auth users = nick
secrets file = /etc/rsyncd.scrt


Welcome to my rsync server!



To sync the “Java2D” projects in the workspaces of the server and client machines (entered in Cygwin on client/remote machine):

$ rsync -vr /Documents and Settings/Nick/workspace/Java2D/ nick@
Welcome to my rsync server!

Password: mybirthday

About these ads
Categories: Linux Tags: ,
  1. April 7, 2009 at 1:47 am

    Many thanks for this saved me no end of time.

  2. April 8, 2009 at 7:37 am

    Glad to have helped!

  3. Jordan
    June 26, 2009 at 10:23 am

    Thanks for the how-to. It seems that that rsync has changed in 9.04. The command to make a backup to the server is as follows:

    $ rsync -vr SRC username@server_ip::workspace

    That’s all I needed to do.

  4. July 23, 2009 at 12:51 pm

    Sorry being dense here.

    When i run locally, it works fine, but i use my system password when challenged.

    When i do it remotely, i always get permission denied errors, whether using system password, or password from my scrt file.

    Any ideas what i’m doing wrong, or how to debug?

  5. July 23, 2009 at 2:20 pm

    never mind i got it working. Thanks!

  6. Joe
    August 11, 2009 at 5:16 am

    Thank-you, great guide, saved me lots of time.

  7. January 19, 2010 at 8:25 pm

    Nice writeup. The rsyncd secrets file needs to be chmod 600 in order for authentication. If it is not then rsyncd will just assume that no valid users exist and deny all connections.

  8. Nichlas
    February 1, 2010 at 10:41 am

    Also remember to chmod 600 rsyncd.scrt

  9. Troy
    June 24, 2010 at 10:29 am

    If I had seen that last comment about chmod 600 rsyncd.scrt, it would have saved me loads of time

  10. sid
    July 25, 2010 at 6:47 am

    For rsync client on Windows check out DeltaCopy. http://www.aboutmyip.com/AboutMyXApp/DeltaCopy.jsp

  11. July 28, 2010 at 12:41 am

    I followed your instructions, they were easy, specially with the example you added. but when I try to sync from the other machine I got auth error, and in the server log I can see:
    secrets file must not be other-accessible (see strict modes option)
    continuing without secrets file
    I found that you should add the following line to the rsyncd.conf
    strict modes = no
    Note: i am using this with two PCs in the same network, and network is trusted. please read about strict mode before applying.
    Thanks for the great article ;)

  12. August 23, 2010 at 6:57 am

    Thanks, very helpful! Make sure you remember to chmod o-r the secrets file if your root user creates files world readable!

  13. Tom
    September 29, 2010 at 2:04 pm

    Anyone know how to edit the /etc/rsyncd.conf file to include the path to a USB drive?

    path = /home/nick/workspace

    I tried path=/media/usbdrive but can’t seem to get it to work.


  14. Lenn
    December 6, 2010 at 1:09 am

    Hi, first of all thanks for the guide, it’s really nice.
    My problem: I can connect with the server but when it is supposed to be syncing i get the error:
    @ERROR: chroot failed
    rsync error: error starting client-server protocol (code 5) at /SourceCache/rsync/rsync-40/rsync/main.c(1398)

    What can be the problem?
    Thx in advance

  15. Lenn
    December 6, 2010 at 1:40 am

    Problem solved:
    My workspace directory on the server wasn’t created yet… my bad!

  16. smaon
    June 15, 2011 at 6:20 am

    Thank you very much, this is the most comprehensive guide I’ve found about rsync! The only thing missing is the chmod 600 for rsync.scrt, but anyway this saved me hours.

  17. fujisan
    June 28, 2011 at 6:39 am

    You can do the same thing without setting up an rsync daemon.

    Just run rsync like this:

    rsync -vr /Documents and Settings/Nick/workspace/Java2D nick@

  18. sb
    September 24, 2011 at 1:48 am


    Yes, you can do the same thing without an rsync deamon but using the deamon will allow user/passwd auth to be independent from the user declared in the system.

    With the deamon “nick” does not have to be a system user. Without the deamon, “nick” must be declared as a system user then migh use other services like ssh.

    When using the deamon, I’d recommend to use a “non-system” user to enhance security (ie “nickrsync”).


  19. Jon Weinraub
    October 18, 2012 at 8:06 am

    How do I set this up in cron so it runs automatically? Obviously I don’t want the password field causing it to fail.

  20. November 8, 2012 at 1:57 pm

    Thank you a lot for sharing this with all folks you really know what you are talking about! Bookmarked. Kindly additionally talk over with my website =). We may have a link change agreement between us

  1. November 16, 2011 at 1:22 pm

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


Get every new post delivered to your Inbox.

%d bloggers like this: