我正在尝试将我的 Raspberry Pi 3 (Raspbian) 备份到我的台式计算机 (Windows 10 Pro)。目前,我可以通过指定私钥文件的方式进行 SSH 连接。
从 Windows 通过 SSH 进入 RPi:(root 以确保在测试期间没有权限错误)。ssh [email protected] -i H:/ssh/BB8.OpenSSH.ppk
要从 RPi 通过 SSH 进入 Windows:ssh [email protected] -i /home/pi/.ssh/RPi3.OpenSSH.ppk
以下 rsync 命令不起作用:(Windows > RPi)
rsync -vvvvna --exclude={"/proc/*","/sys/*","/dev/*","/boot/*","/tmp/*","/run/*","/mnt/*"} -e "ssh -i H:/ssh/BB8.OpenSSH.ppk" [email protected]:/* /cygdrive/h/Users/Matt/Documents/RPi3_Backup
Rsync 说“连接意外关闭”,而 RPi SSH 日志说它“从 192.168.1.100 断开连接”。
Rsync 输出:
cmd=ssh -i H:/ssh/BB8.OpenSSH.ppk machine=192.168.1.107 user=root path=/*
cmd[0]=ssh cmd[1]=-i cmd[2]=H:/ssh/BB8.OpenSSH.ppk cmd[3]=-l cmd[4]=root cmd[5]=192.168.1.107 cmd[6]=rsync cmd[7]=--server cmd[8]=--sender cmd[9]=-vvvvnlogDtpre.iLsfxC cmd[10]=. cmd[11]=/*
opening connection using: ssh -i "H:/ssh/BB8.OpenSSH.ppk" -l root 192.168.1.107 rsync --server --sender -vvvvnlogDtpre.iLsfxC . "/*" (12 args)
msg checking charset: UTF-8
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
[sender] _exit_cleanup(code=12, file=io.c, line=235): entered
rsync error: error in rsync protocol data stream (code 12) at io.c(235) [sender=3.1.2]
[sender] _exit_cleanup(code=12, file=io.c, line=235): about to call exit(12) (DRY RUN)
rsync: safe_read failed to read 4 bytes [Receiver]: Connection reset by peer (104)
[Receiver] _exit_cleanup(code=12, file=io.c, line=276): entered
rsync error: error in rsync protocol data stream (code 12) at io.c(276) [Receiver=3.1.2]
[Receiver] _exit_cleanup(code=12, file=io.c, line=276): about to call exit(12) (DRY RUN)
/var/log/auth.log:
May 27 20:01:20 raspberrypi sshd[9928]: Accepted publickey for root from 192.168.1.100 port 56787 ssh2: RSA SHA256:bYwS/mZ7XYmMlim3gEaSxZ+p22wU3i0NypvFj6ZPPAA
May 27 20:01:20 raspberrypi sshd[9928]: pam_unix(sshd:session): session opened for user root by (uid=0)
May 27 20:01:20 raspberrypi systemd-logind[476]: New session c33 of user root.
May 27 20:01:20 raspberrypi systemd: pam_unix(systemd-user:session): session opened for user root by (uid=0)
May 27 20:01:20 raspberrypi sshd[9928]: Received disconnect from 192.168.1.100 port 56787:11: disconnected by user
May 27 20:01:20 raspberrypi sshd[9928]: Disconnected from 192.168.1.100 port 56787
May 27 20:01:20 raspberrypi sshd[9928]: pam_unix(sshd:session): session closed for user root
May 27 20:01:20 raspberrypi systemd-logind[476]: Removed session c33.
May 27 20:01:20 raspberrypi systemd: pam_unix(systemd-user:session): session closed for user root
答案1
典型情况——我在这里发布帖子后就解决了这个问题(这个问题持续了整整一个晚上,并且经过了几个小时的调试......)
可以作为可选 Windows 10 功能启用的 OpenSSH 服务器似乎与 Cygwin 的 rsync 配合使用效果不佳。我通过 Cygwin 安装了 OpenSSH,一切都按预期连接。
rsync -nva --exclude={"/proc/*","/sys/*","/dev/*","/boot/*","/tmp/*","/run/*","/mnt/*"} -e "C:/cygwin64/bin/ssh.exe -i /cygdrive/h/ssh/BB8.OpenSSH.ppk" [email protected]:/* /cygdrive/h/Users/Matt/Documents/RPi3_Backup