You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

WSL2通过rsync向远程Ubuntu EC2服务器传目录失败求助

从WSL2通过rsync同步目录到AWS EC2失败问题

环境与前提

  • WSL2 Ubuntu环境,操作目录为C盘下的testfolder(内含test.txt)
  • 远程Ubuntu EC2已配置:安全组开放0.0.0.0/0的22端口,SSH密钥可正常登录,已在~目录创建test文件夹

尝试过的rsync命令及错误

命令1

rsync -rv ./testfolder/ ubuntu@000.00.00.000:.~/test

错误输出:

ssh: connect to host 000.00.00.000 port 22: Connection timed out
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(231) [sender=3.2.7]

命令2

rsync -avrzv --rsync-path "sudo rsync" -e "ssh -i ~/path.pem" ./testfolder/ ubuntu@000.00.00.000:~/test

错误输出:

ssh: connect to host 000.00.00.000 port 22: Connection timed out
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(231) [sender=3.2.7]

命令3(尝试rsync守护进程模式,明知不适用仍测试)

rsync -avrzv --rsync-path "sudo rsync" -e "ssh -i ~/path.pem" ./testfolder/ rsync://ubuntu@000.00.00.000:~/test

错误输出:

ssh: connect to host 000.00.00.000 port 22: Connection timed out
rsync: did not see server greeting
rsync error: error starting client-server protocol (code 5) at main.c(1863) [sender=3.2.7]

针对22端口超时的排查操作

  1. 检查rsync服务状态:
systemctl list-unit-files |grep rsync

输出:

rsync.service disabled enabled
  1. 启用rsync服务:
sudo systemctl enable rsync.service

输出:

Synchronizing state of rsync.service with SysV service script with /lib/systemd/systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install enable rsync
  1. 启动rsync服务:
sudo systemctl start rsync.service

再次检查状态:

systemctl list-unit-files |grep rsync

输出:

rsync.service enabled enabled
  • 已尝试添加--timeout 9999参数,问题依旧

额外网络测试结果

在WSL2中执行ping命令:

ping 000.00.00.000

输出:

PING 000.00.00.000 (000.00.00.000) 56(84) bytes of data. From 11.11.11.111 icmp_seq=166 Destination Net Unreachable

远程EC2状态确认

  • 已通过sshd相关命令确认22端口正常监听
  • 当前已有其他SSH连接处于活跃状态

内容的提问来源于stack exchange,提问作者Bob Linux

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.05 21:18:23