Set up anonymous FTP upload on Oracle Linux

Jan 11, 2012 · oracle-linux, selinux, vsftpd

[ Note that I am in the process of migrating these blog posts from Wordpress, and as such it may contain incorrect formatting, missing links, etc. My old site is available at http://www-old.perkin.org.uk/ so if you find something obviously broken please let me know. Thanks! ]

Just because this took a little longer than I expected, here’s a quick howto for setting up an anonymous FTP drop-off on Oracle Linux, which I use as a simple way to transfer files out of my Virtual Machines.

Install vsftpd

$ sudo yum -y install vsftpd

Configure iptables

As FTP is a more complicated protocol than most, there is a special netfilter module required in order to correctly keep track of connections.

# You will perhaps want to change the insert number here.
$ sudo iptables -I INPUT 4 -m state --state NEW -p tcp --dport 21 -j ACCEPT
$ sudo /etc/init.d/iptables save

Add nf_conntrack_ftp to IPTABLES_MODULES

$ sudo vi /etc/sysconfig/iptables-config

Then load the module rather than reboot

$ sudo modprobe nf_conntrack_ftp

Create /incoming

Create /incoming area and ensure it has the correct file permissions and SELinux context. This is the bit which had me stumped for a little while, as I didn’t know about allow_ftpd_anon_write, and while I normally just disable SELinux, I do also like to know how things should work (and be able to write about them!):

$ sudo mkdir /var/ftp/incoming
$ sudo chown ftp:ftp /var/ftp/incoming

# This allows anonymous users to upload, but not see what''s in the directory
$ sudo chmod 750 /var/ftp/incoming

$ sudo chcon -u system_u -t public_content_rw_t /var/ftp/incoming
$ sudo setsebool allow_ftpd_anon_write=1

Configure vsftpd

$ sudo vi /etc/vsftpd/vsftpd.conf
anon_upload_enable=YES

Startup

Finally, enable and start vsftpd:

$ sudo chkconfig vsftpd on
$ sudo /etc/init.d/vsftpd start

And that’s it, you should now be able to FTP as anonymous and upload files into /incoming.


All blog posts

Feb 20, 2012 » New blog design
Jan 11, 2012 » Set up anonymous FTP upload on Oracle Linux
Jan 09, 2012 » Kickstart Oracle Linux in VirtualBox
Jan 09, 2012 » Kickstart Oracle Linux from Ubuntu
Dec 22, 2011 » Last day at MySQL
Dec 15, 2011 » Installing OpenBSD with softraid
Sep 21, 2011 » Create VirtualBox VM from the command line
Sep 14, 2011 » Creating chroots for fun and MySQL testing
Jun 30, 2011 » Graphing memory usage during an MTR run
Jun 29, 2011 » Fix input box keybindings in Firefox
Jun 24, 2011 » How to lose weight
Jun 23, 2011 » How to fix stdio buffering
Jun 13, 2011 » Serving multiple DNS search domains in IOS DHCP
Jun 13, 2011 » Fix Firefox URL double click behaviour
Apr 20, 2011 » SSH via HTTP proxy in OSX
Nov 09, 2010 » How to build MySQL releases
Apr 29, 2010 » 'apt-get' and 5,000 packages for Solaris10/x86
Sep 16, 2009 » ZFS+NFS vs OSX
Sep 12, 2009 » pkgsrc on Solaris
Dec 09, 2008 » Jumpstart from OSX