Ubuntu - Set Up Rsync Server
I've used rsync in the past, but I only used it to:
- create a local backup
- grab files from a remote rsync server for a mirror.
- updated a remote server over SSH.
In this tutorial, I am going to show you how you can set up your server to accept rsync connections with a separate user/authentication list to your computer's local user accounts. This is more like samba or FTP where your server accepts file transfers with login details that aren't local users.
Create the rsyncd.conf file (chances are that it deosn't already exist).
sudo editor /etc/rsyncd.conf
Put the following content in, obviously swapping out the relevant configuration variables like uid or gid.
lock file = /var/run/rsync.lock log file = /var/log/rsyncd.log pid file = /var/run/rsyncd.pid [code] path = /home/programster/code comment = Programsters code folder uid = programster gid = programster read only = no list = yes auth users = programster secrets file = /etc/rsyncd.secrets hosts allow = 192.168.1.0/255.255.255.0
Please refer to the rsyncd.conf(5) - Linux man page for details of what these options do, and to see if there are any others that you might need to use (like port). Hopefully most of the ones provided are self explanatory. Remember that uid and gid are the user and group of the local machine user that will be used when accessing/creating files, and do not have to be the same username as you use to connect to the rsync server as.
Create Authentication File
You will have seen that in the configuration file, we had a
secrets file option. We now need to create that file.
This file will contain the usernames and passwords of the accounts you wish to allow to connect to the rsync service.
Remember that the username and passwords can be completely separate from the local user accounts, and when your client connects using rsync, they will need to specify the user/password here, not a local user.
sudo vim /etc/rsyncd.secrets
Fill in the usernames and passwords like so:
Give the file the following permissons:
sudo chmod 600 /etc/rsyncd.secrets
Release the Demon!
Now that we have configured our rsync server, we need to start it so that our server listens for incoming rsync requests,
Managing The Rsync Daemon With Systemctl
The easiest way to manage the rsync daemon in Ubuntu 16.04 is to use:
sudo systemctl start rsync
If you want the rsync daemon to start up on boot, then use this command:
sudo systemctl enable rsync
If you have been using systemctl to manage the rsync daemon, then stopping it can e done with:
sudo systemctl stop rsync
Manually Managing the Rsync Daemon
If you wish to manually manage the rsync daemon, then you can launch it with the following command:
sudo rsync --daemon
... and then you would kill it with:
sudo kill `cat /var/run/rsyncd.pid`
- Juan Valencia's website - Running rsync as a daemon
- Banaspati - How to configure rsync as daemon on ubuntu 16.04
First published: 16th August 2018