Writeable Rsync server with authentication

In my previous post we talked about how to setup a simple read-only rsync server. In this post,  we’ll be taking that simple read-only example and expanding it to allow multiple users, each with their own credentials.

In order to do this, we need to modify the /etc/rsyncd.conf file, and change the following lines:

read only = no
auth users = bozo
secrets file = /etc/rsyncd.secrets

Note that “bozo” is the username of a fake user we’re going to create. We can see in this configuration that we’re pointing to a file under /etc/rsyncd.secrets. We’re going to have to create this file and populate it with the credentials for any users we have created. In this case, we populate it with bozo’s username and password:


We also have to set the permissions on this file to make sure that it’s only readable by the root user, using the chmod command:

chmod 600 /etc/rsyncd.secrets

Now, usually we would run the “reload” command to send a message to the server to reload its configuration, but when we do this for rsync, we get the following message:

$ service rsync reload
 * Reloading rsync daemon: not needed, as the daemon
 * re-reads the config file whenever a client connects.

Which is very useful indeed. Now when we connect from the client side, we have to do so using the credentials which we’ve just created. The command looks like:

rsync -r bozo@ .

This will ask us for a password, which we know is “clown” from before after which the copy should start as usual. If you want to test out the write capability of the server, we just need to create a file in our current directory and then execute the rsync command going the other way:

rsync -r . bozo@

In the future we might want to automate the rsync process in order to have it run as a cron job or other automated job. This means that we won’t have a human there to enter the password. This can be gotten around with by using the “–password-file” option of the rsync command, like so:

rsync –password-file=~/.rsync_pass -r . bozo@

Note that as with the rsyncd.secrets file mentioned previously, you’ll have to change the permissions on this file to ensure that it’s not world readable. The file itself just needs to contain the password to use and nothing else.

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 )

Google photo

You are commenting using your Google 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 )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.