I am attempting to make a copy of the /home folder on a remote Raspberry Pi (pitwo) to a local Raspberry Pi (pizero) via rsync and ssh. The local Pi has a hard drive connected that is shared using samba and the /home folder on PiTwo should be copied to in the /mnt/BigMac/BigMac/PiBackups/PiTwo folder on PiZero. I have the necessary ssh keys and can successfully make an ssh connection from PiTwo to PiZero using Terminal. My problem is that I cannot successfully connect using ssh keys and rsync.
So far, I've tried:
import os
os.system('rsync -auvz -e "ssh -i /home/PiTwo/.ssh/id_rsa" /home [email protected]:/mnt/BigMac/BigMac/PiBackups/PiTwo/home')
This gives me the following error:
ssh_askpass: exec(/usr/bin/ssh-askpass): No such file or directory
Permission denied, please try again.
ssh_askpass: exec(/usr/bin/ssh-askpass): No such file or directory
Permission denied, please try again.
ssh_askpass: exec(/usr/bin/ssh-askpass): No such file or directory
[email protected]: Permission denied (publickey,password).
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: error in rsync protocol data stream (code 12) at io.c(228) [sender=3.2.3]
I also tried:
import os
os.system('rsync -r -a ssh [email protected]:/mnt/BigMac/BigMac/PiBackups/PiTwo /home')
This gives following errors:
Unexpected remote arg: [email protected]:/mnt/BigMac/BigMac/PiBackups/PiTwo
rsync error: syntax or usage error (code 1) at main.c(1499) [sender=3.2.3]
``
Would appreciate any help in getting the correct syntax.
rsync
command work if you run it in the shell normally (instead of in python)? Does/usr/bin/ssh-askpass
exist on your system? Try installing it if not. I think that's the tool that prompts you to accept unkown host keys, so you may also need to pre-import or accept the remote host key into known_hostsscp
You can also disable host key checking withssh -o StrictHostKeyChecking=no user@remote-host