在Debian Proftpd – 文件传输的麻烦

我有一个租用的VPS wieh debian安装。 最近我已经安装了proftpd,以允许只读访问每个人和完全访问特定用户。

我根据几个指南configuration了proftpd(使用TLS)。 我已经解锁被动端口(通过iptables的端口和21端口),并设置匿名login。

当我login时,一切正常 – 快速login,快速通过目录…当我尝试下载文件时发生问题 – winscp / filezilla / python,所有卡住下载文件,然后松散连接(文件是〜 1kB,非常小)。 当我通过SFTP连接到服务器时,我没有问题和全速。

有任何想法吗? 你需要我的proftpd.conf文件吗?

更新:

我看到我需要添加一些信息,这要感谢第一个评论(关于SCP):

  • 我希望能够匿名查看文件,最好是通过networking浏览器,但它不是必须的。
  • 我需要设置一个应用程序,从VPS与我的硬盘上的文件夹同步整个文件夹(我打算通过python来做到这一点,但shell / bash也不错)
  • 我希望能够下载/上传整个目录或只有那些已经改变的文件
  • 我需要这个没有第三方程序是可行的。 通过cmdline / bash或官方的python库。 需要在Windows和Fedora上工作

我的iptablesconfiguration:

 Chain INPUT (policy ACCEPT) target prot opt source destination fail2ban-ssh-ddos tcp -- anywhere anywhere multiport dports ssh ACCEPT tcp -- anywhere anywhere tcp dpts:60000:65535 fail2ban-ssh tcp -- anywhere anywhere multiport dports ssh ACCEPT tcp -- anywhere anywhere tcp dpt:ftp Chain FORWARD (policy ACCEPT) target prot opt source destination Chain OUTPUT (policy ACCEPT) target prot opt source destination Chain fail2ban-ssh (1 references) target prot opt source destination RETURN all -- anywhere anywhere Chain fail2ban-ssh-ddos (1 references) target prot opt source destination RETURN all -- anywhere anywhere 

我closures了TLS,通过访客帐户连接,打开二进制模式,并启动端口21(serverside ofc)上的tcpdump。 然后我做了一个单一的文件“获得”,过了一段时间,我得到了“通过远程主机closures连接”。 这里是ftpinput:

 ftp> get light.cfg 200 PORT command successful 150 Opening BINARY mode data connection for light.cfg (94 bytes) Connection closed by remote host. 

在这里你可以看到get和connection_closed分隔一行:

 15:12:15.836468 IP (tos 0x0, ttl 119, id 30359, offset 0, flags [DF], proto TCP (6), length 67) 83-144-76-138.static.chello.pl.54225 > vz31640.dahost.pl.ftp: Flags [P.], cksum 0x5526 (correct), seq 139:166, ack 575, win 7618, length 27 15:12:15.836636 IP (tos 0x0, ttl 64, id 50952, offset 0, flags [DF], proto TCP (6), length 69) vz31640.dahost.pl.ftp > 83-144-76-138.static.chello.pl.54225: Flags [P.], cksum 0x7049 (correct), seq 575:604, ack 166, win 115, length 29 15:12:15.856530 IP (tos 0x0, ttl 119, id 30360, offset 0, flags [DF], proto TCP (6), length 56) 83-144-76-138.static.chello.pl.54225 > vz31640.dahost.pl.ftp: Flags [P.], cksum 0xd20f (correct), seq 166:182, ack 604, win 7589, length 16 15:12:15.868348 IP (tos 0x0, ttl 64, id 50953, offset 0, flags [DF], proto TCP (6), length 106) vz31640.dahost.pl.ftp > 83-144-76-138.static.chello.pl.54225: Flags [P.], cksum 0xba9a (correct), seq 604:670, ack 182, win 115, length 66 15:12:15.934002 IP (tos 0x0, ttl 119, id 30365, offset 0, flags [DF], proto TCP (6), length 40) 83-144-76-138.static.chello.pl.54225 > vz31640.dahost.pl.ftp: Flags [.], cksum 0x0ccc (correct), ack 670, win 7523, length 0 15:13:15.909873 IP (tos 0x0, ttl 119, id 30372, offset 0, flags [DF], proto TCP (6), length 40) 83-144-76-138.static.chello.pl.54225 > vz31640.dahost.pl.ftp: Flags [F.], cksum 0x0ccb (correct), seq 182, ack 670, win 7523, length 0 15:13:15.910056 IP (tos 0x0, ttl 64, id 50954, offset 0, flags [DF], proto TCP (6), length 40) vz31640.dahost.pl.ftp > 83-144-76-138.static.chello.pl.54225: Flags [F.], cksum 0x29ba (correct), seq 670, ack 183, win 115, length 0 15:13:15.922725 IP (tos 0x0, ttl 119, id 30373, offset 0, flags [DF], proto TCP (6), length 40) 83-144-76-138.static.chello.pl.54225 > vz31640.dahost.pl.ftp: Flags [.], cksum 0x0cca (correct), ack 671, win 7523, length 0 

请发布您的iptables安装程序。 请注意,使用FTP工作可能会非常棘手,因为FTP使用dynamic端口分配(在被动模式下,当客户端要下载或上载文件时,服务器为数据传输stream分配一个dynamic端口,并将其通知客户端并期望客户端连接到它)。

意即:

  1. 如果要在Netfilter中使用一些“有状态”的方法来检测FTP数据stream,则需要加载专用的内核模块来解码控制FTPstream;
  2. 这对TLS无效,因为内核将无法解码所述FTP控制stream。

SCP(和SFTP)工作正常,因为它们在单个TCPstream中复用控制和数据stream。

至于同步…首先,由于这是一个遗留协议,因此忘记了scp ; 改用SFTP。 这似乎是一个跨平台的Python SFTP实现,所以它可能只适用于你。 顺便说一句,Windows有良好的支持SFTP前端软件(谷歌为WinSCP)。

你也可以考虑其他的同步手段。 例如, rsync具有Windows版本,它是现有的最好的文件系统同步工具。 你也可以考虑WebDAV或者甚至实现一些RESTful。