Open bahree opened 3 years ago
Sorry for my late response. A permission denied would suggest that the account info is not correct.
I'm having a similar issue, but I've checked and the details are definitely correct. I can ssh from the "primary" pi-hole (192.168.1.2) to the "secondary" pi-hole (192.168.1.3) without issue.
On running the script, I'm asked for a password, but input isn't accepted.
Here's my output:
/etc/pihole ❯ sudo ./pi_rsync.sh -s
Running command service pihole-FTL stop on {192.168.1.3}
[sudo] password for [my-username]: Syncing {gravity.db} over to {192.168.1.3}...
bash: rsync: command not found
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: error in rsync protocol data stream (code 12) at io.c(235) [sender=3.1.3]
Syncing {custom.list} over to {192.168.1.3}...
bash: rsync: command not found
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: error in rsync protocol data stream (code 12) at io.c(235) [sender=3.1.3]
Syncing {local.list} over to {192.168.1.3}...
bash: rsync: command not found
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: error in rsync protocol data stream (code 12) at io.c(235) [sender=3.1.3]
Running command pkill pihole-FTL on {192.168.1.3}
[sudo] password for [my-username]: Running command service pihole-FTL start on {192.168.1.3}
[sudo] password for [my-username]: Running command pihole restartdns reload-lists on {192.168.1.3}
[sudo] password for [my-username]:
Having spent a bit more time looking into this, I've finally stumbled upon the (obvious) solution.
The user on the secondary Pi-Hole needs to have write access to the /etc/pihole
directory, otherwise the permissions error will be displayed. As most of the files in that directory are owned by root, it's necessary to either set permissions to 777 (not good for obvious reasons) or run the rsync as the root user on the secondary Pi-Hole (also not ideal, but an OK workaround).
Also, rsync
must be installed on both Pi-Holes.
What OS are you using? I used Raspian and Debian. I need to test some more and it would be good to find a solution that works for everyone and are as secure as we can manage.
I know this thread is old but the /etc/pihole folder is set for pihole:pihole so one solution is to add the pi user to the pihole group. From there the script works properly.
@miarn After stupidly struggling for a few hours trying to modify the script to get it working, finally realized the issue after reading your comment. Thank you!
Hi, this is interesting and seems quite simple - thank you for sharing.
When I set this up unfortunately I get a permissions denied error when I run this - any ideas on what am I doing wrong?
Here is what I get when manually running this from the 'master pihole' to the secondary one.
Thanks.