Article

  • 9 years

    8 years

    YetiShare / Core

    4160

Using FTP file storage, files are being stored with 0 bytes when uploaded

Problem

When using a FTP server for storage, you try to upload a file and it's saved as 0 bytes on the FTP server. All tests via the script admin area seem to show it's working fine.

Fix

This is likely an issue with iptables restricting the transfer to your FTP server. Use the GUI to enable FTP:

sudo system-config-firewall-tui
service iptables restart

Alternatively, run these commands as the root SSH user:

First load the following module to make sure passive ftp connections are not rejected

modprobe ip_conntrack_ftp 
Allow FTP connections on port 21 incoming and outgoing

iptables -A INPUT -p tcp -m tcp --dport 21 -m conntrack --ctstate ESTABLISHED -j ACCEPT -m comment --comment "Allow ftp connections on port 21"
iptables -A OUTPUT -p tcp -m tcp --dport 21 -m conntrack --ctstate NEW,ESTABLISHED -j ACCEPT -m comment --comment "Allow ftp connections on port 21" 
Allow FTP port 20 for active connections incoming and outgoing

iptables -A INPUT -p tcp -m tcp --dport 20 -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT -m comment --comment "Allow ftp connections on port 20"
iptables -A OUTPUT -p tcp -m tcp --dport 20 -m conntrack --ctstate ESTABLISHED -j ACCEPT -m comment --comment "Allow ftp connections on port 20" 
Finally allow FTP passive inbound traffic

iptables -A INPUT -p tcp -m tcp --sport 1024: --dport 1024: -m conntrack --ctstate ESTABLISHED -j ACCEPT -m comment --comment "Allow passive inbound connections"
iptables -A OUTPUT -p tcp -m tcp --sport 1024: --dport 1024: -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT -m comment --comment "Allow passive inbound connections"
If none of the above work you can format your iptables with the following command. Note that this will clear any previous settings though:

iptables -F