0

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.
3
  • does the entire 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_hosts
    – Cpt.Whale
    Commented Apr 5, 2023 at 16:50
  • If you only need a one-time copy, I suggest trying this with scp You can also disable host key checking with ssh -o StrictHostKeyChecking=no user@remote-host
    – M Virts
    Commented Apr 5, 2023 at 17:06
  • Using the rsync command in Terminal throws errors too. I will use the command in a Python script daily in the middle of the night to use as a backup of the folder, hence the use of ssh keys.
    – Kevin
    Commented Apr 5, 2023 at 17:44

0

You must log in to answer this question.

Browse other questions tagged .