Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rsync with sshpass on Linux using systemd: 'Host key verification failed.'

I am trying to set up rsync with sshpass on a RaspberryPi to connect to a Synology drive in order to synchronize data.

The listed command:

sshpass -p 'password' rsync -avz -e 'ssh -p 22' \home\pi host@IP::home/example

works out fine, if I run it manually at the command prompt. As well it works out, when I implement it into a python script using the package 'subprocess':

import subprocess
subprocess.run([ sshpass -p 'password' rsync -avz -e 'ssh -p 22' \home\pi host@IP::home/example])

Whenever I want to autostart the python script using systemctl as a service, I get the following error:

Host key verification failed. rsync error: received SIGINT, SIGTERM or SIGHUP (code 20) at rsync.c(644) [sender=3.1.3]

I am wondering, what ist the difference between the command prompt and systemd in this case?

Thank you so much for your help in advance! I really appreciate every Tip!!! Kilian

like image 398
Kilian Avatar asked Oct 15 '25 14:10

Kilian


1 Answers

The rude way is to add -o "StrictHostKeyChecking=no" to your SSH command:

sshpass -p 'password' rsync -avz -e 'ssh -o "StrictHostKeyChecking=no" -p 22' \home\pi host@IP::home/example
like image 185
Alexander Ivanov Avatar answered Oct 17 '25 23:10

Alexander Ivanov



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!