我正在尝试复制/家通过 rsync 和 ssh 将远程 Raspberry Pi (pitwo) 上的文件夹复制到本地 Raspberry Pi (pizero)。本地 Pi 连接了一个使用 samba 共享的硬盘,并且/家文件夹应该复制到 PiTwo 中/mnt/BigMac/BigMac/PiBackups/PiTwoPiZero 上的文件夹。我拥有必要的 ssh 密钥,可以使用终端成功建立从 PiTwo 到 PiZero 的 ssh 连接。我的问题是我无法使用 ssh 密钥和 rsync 成功连接。
到目前为止,我已经尝试过:
import os
os.system('rsync -auvz -e "ssh -i /home/PiTwo/.ssh/id_rsa" /home [email protected]:/mnt/BigMac/BigMac/PiBackups/PiTwo/home')
这给了我以下错误:
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]
我也尝试过:
import os
os.system('rsync -r -a ssh [email protected]:/mnt/BigMac/BigMac/PiBackups/PiTwo /home')
这会出现以下错误:
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.