Ssh
Cygwin Windows < Linux rsync - 連接意外關閉
我正在嘗試將我的 Raspberry Pi 3 (Raspbian) 備份到我的台式電腦 (Windows 10 Pro)。目前我可以通過各種方式進行 SSH,指定私鑰文件。
從 Windows SSH 進入 RPi:
ssh root@192.168.1.107 -i H:/ssh/BB8.OpenSSH.ppk
(root 以確保我在測試期間沒有權限錯誤)。從 RPi SSH 到 Windows:
ssh matt@192.168.1.100 -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" root@192.168.1.107:/* /cygdrive/h/Users/Matt/Documents/RPi3_Backup
Rsync 說“連接意外關閉”,而 RPi SSH 日誌說它“收到與 192.168.1.100 的斷開連接”。
同步輸出:
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
典型的——我一在這裡發帖就解決了問題(這個問題一直持續到晚餐和數小時的調試……)
可以作為可選 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" root@192.168.1.107:/* /cygdrive/h/Users/Matt/Documents/RPi3_Backup