Windows

從 Windows 到 CentOS 的 Rync 連接問題

  • February 18, 2012

嘗試從 Windows 7 上的 Cygwin 連接到 CentOS 上的 rsync,但出現以下錯誤:

$ rsync -vrtz -vvv --password-file=c:\cygwin\secret --delete /cygdrive/d/Data username@xx.xx.xx.xx::modulename

opening tcp connection to xx.xx.xx.xx port 873
rsync: failed to connect to xx.xx.xx.xx (xx.xx.xx.xx): Connection timed out (116)
[sender] _exit_cleanup(code=10, file=/home/lapo/package/rsync-3.0.9-1/src/rsync-3.0.9/clientserver.c, line=122): entered
rsync error: error in socket IO (code 10) at /home/lapo/package/rsync-3.0.9-1/src/rsync-3.0.9/clientserver.c(122) [sender=3.0.9]
[sender] _exit_cleanup(code=10, file=/home/lapo/package/rsync-3.0.9-1/src/rsync-3.0.9/clientserver.c, line=122): about to call exit(10)

我可以從同一台 Windows 機器上的 putty SSH 到這個伺服器。我也可以直接ping IP 地址。

我是否需要確保打開特定埠以供 rsync 連接?

更新

正在做

cat /etc/services | grep rsync

退貨

rsync           873/tcp                         # rsync
rsync           873/udp                         # rsync

另一個更新

iptables -L

輸出:

Chain INPUT (policy ACCEPT)
target     prot opt source               destination
RH-Firewall-1-INPUT  all  --  anywhere             anywhere
          tcp  --  anywhere             anywhere            tcp dpt:ftp
ACCEPT     tcp  --  anywhere             anywhere            tcp dpt:ftp

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination
RH-Firewall-1-INPUT  all  --  anywhere             anywhere

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination

Chain RH-Firewall-1-INPUT (2 references)
target     prot opt source               destination
ACCEPT     all  --  anywhere             anywhere
ACCEPT     icmp --  anywhere             anywhere            icmp any
ACCEPT     esp  --  anywhere             anywhere
ACCEPT     ah   --  anywhere             anywhere
ACCEPT     udp  --  anywhere             224.0.0.251         udp dpt:mdns
ACCEPT     udp  --  anywhere             anywhere            udp dpt:ipp
ACCEPT     tcp  --  anywhere             anywhere            tcp dpt:ipp
ACCEPT     all  --  anywhere             anywhere            state RELATED,ESTABLISHED
ACCEPT     tcp  --  anywhere             anywhere            state NEW tcp dpt:ssh
REJECT     all  --  anywhere             anywhere            reject-with icmp-host-prohibited

netfilter您在 CentOS 伺服器上執行了預設規則集。

如果此主機僅供內部使用(不可公開訪問),您可以禁用防火牆:

service iptables stop
chkconfig iptables off

但是,最好只允許 rsync 埠:

iptables -A INPUT -p tcp --dport 873 -j ACCEPT
service iptables save

引用自:https://serverfault.com/questions/361467