The connection was refused because you were using a non-standard rsync port, see the comments by user roaima.
For simplicity, I expect user public_rsync with home directory /home/public_rsync exists on the destination host (192.xxx.xxx.xxx, where the daemon is running) and the service is not blocked by your firewall.
Start with this sample /etc/rsyncd.conf (passwords are enabled later):
pid file = /var/run/rsyncd.pid
lock file = /var/run/rsync.lock
log file = /var/log/rsync.log
[checkpoints]
path = /home/public_rsync/checkpoints
comment = RSYNC FILES
read only = false
uid = public_rsync
gid = public_rsync
#auth users = secondaryvm
#secrets file = /etc/rsyncd.secrets
timeout = 300
Explanation:
- remove
port = 12000 to use default port 873
- change module name from
[files] to [checkpoints]
- change the path to the module directory to
/home/public_rsync/checkpoints
- change
read only = true to false to be able to push files to the server
- add
uid / gid to use this username / group when transferring files
Then restart the server:
sudo systemctl restart rsync
1. Test rsync on the destination host as user public_rsync
List all listable modules with rsync localhost::, it should return the module name and the description:
public_rsync@192.xxx.xxx.xxx:~$ rsync localhost::
checkpoints RSYNC FILES
Create directory checkpoints and a test file in this directory:
public_rsync@192.xxx.xxx.xxx:~$ mkdir ~/checkpoints
public_rsync@192.xxx.xxx.xxx:~$ echo helloworld > ~/checkpoints/helloworld.txt
List all files of our module:
public_rsync@192.xxx.xxx.xxx:~$ rsync localhost::checkpoints
drwxrwxr-x 4,096 2020/10/30 18:26:01 .
-rw-rw-r-- 11 2020/10/30 18:26:01 helloworld.txt
2. Test rsync from the source host, make sure pull/push are working
Test pull:
$ rsync 192.xxx.xxx.xxx::checkpoints/helloworld.txt /tmp/
$ cat /tmp/helloworld.txt
helloworld
Test push:
$ rsync /tmp/helloworld.txt 192.xxx.xxx.xxx::checkpoints/helloworld_push.txt
List files of module checkpoints again:
$ rsync 192.xxx.xxx.xxx::checkpoints
drwxrwxr-x 4,096 2020/10/30 18:29:06 .
-rw-rw-r-- 11 2020/10/30 18:26:01 helloworld.txt
-rw-r--r-- 11 2020/10/30 18:29:06 helloworld_push.txt
3. Enable authentication
Now that we know rsync works as expected, enable authentication on the destination host:
Create text file /etc/rsyncd.secrets with username and password for user secondaryvm (the username is arbitrary, no user account needed):
user@192.xxx.xxx.xxx:~$ sudo tee /etc/rsyncd.secrets > /dev/null <<'EOF'
secondaryvm:12345
EOF
user@192.xxx.xxx.xxx:~$ sudo chmod 600 /etc/rsyncd.secrets
Uncomment auth users and secrets file in /etc/rsyncd.conf, restart the server:
user@192.xxx.xxx.xxx:~$ sudo systemctl restart rsync
4. Test authentication (from source host)
Connecting without credentials should not be possibly any more, you're supposed to enter a password:
$ rsync 192.xxx.xxx.xxx::checkpoints
Password:
@ERROR: auth failed on module checkpoints
rsync error: error starting client-server protocol (code 5) at main.c(1675) [Receiver=3.1.3]
Provide username and password for the connection, e.g.
$ echo '12345' > rsync_pass
$ chmod 600 rsync_pass
$ rsync --password-file=rsync_pass secondaryvm@192.xxx.xxx.xxx::checkpoints
If anything doesn't work, add verbosity with option -v and check the daemon log /var/log/rsync.log.
/etc/rsyncd.conf. Areauth usersandsecrets filedefined and properly setup? – Freddy Oct 30 '20 at 08:02sudo systemctl status rsyncon backup side – y_159 Oct 30 '20 at 10:28checkpointsbut your configuration definesfiles– Chris Davies Oct 30 '20 at 21:13