[arch-general] inotify and rsync as user
Hello, I have question to the combination of inotify and rsync. I want that my documents folder sync with other maschine if the host is up. So I find this soulution in net. The problem is, I write a script take it in /usr/local/bin cat /usr/local/bin/sync_docs.sh #!/usr/bin/env bash if ping -c 1 192.168.2.160 &> /dev/null; then while true; do inotifywait -r -e modify,attrib,close_write,move,create,delete /home/siefke/Dokumente rsync -avuq /home/siefke/Dokumente/ samsung:/home/siefke/Dokumente/ done fi and a systend service file. So but when the script run I become ever error siefke@192.168.2.160: Permission denied (publickey,password). So I place the script in home folder, place systemd service file in home and run it with systemd --user. The result is same. When run ssh samsung it works, when I run sync_docs.sh in shell it works. Why with systemd make it trouble? Thank you Silvio
siefke@192.168.2.160: Permission denied (publickey,password).
So I place the script in home folder, place systemd service file in home and run it with systemd --user.
The result is same. When run ssh samsung it works, when I run sync_docs.sh in shell it works. Why with systemd make it trouble?
service needs SSH_AUTH_SOCK iirc. [Service] Environment=SSH_AUTH_SOCK=%t/gnupg/S.gpg-agent.ssh (or wherever the socket is located on your machine)
Hi,
I have question to the combination of inotify and rsync. I want that my documents folder sync with other maschine if the host is up. So I find this soulution in net.
maybe it would be less pain using something like https://syncthing.net/ - it also watches for file changes and syncs documents over your network, and also if one device is outside your network. Regards Bjoern
Le samedi 2 mai 2020 11:42:37 CEST siefke_listen@web.de a écrit :
The result is same. When run ssh samsung it works, when I run sync_docs.sh in shell it works. Why with systemd make it trouble?
Thank you Silvio
I do some rsync replication based on cron jobs, without inotify nor systemd. keychain unscrewed the script for automation to succeed. At the top of the script : keychain --agents "ssh" &> /dev/null . $HOME/.keychain/$(hostname)-sh ssh-add &> /dev/null # ... rsync something ... This supposes that you have rightly setup SSH keys on both hosts, and that the private key on the source host is not encrypted. In case it might help. Regards.
participants (4)
-
Bjoern Franke
-
ml
-
SET
-
siefke_listen@web.de