in Security

Ban File Extensions Using Pure-ftpd

Pure-ftpd has no direct support to prevent files with certain extensions from being uploaded. But it’s possible to accomplish this goal using a pure-ftp feature. pure-ftpd has a post-upload program that runs after each file is successfully uploaded and can run an external program. Here’s the excerpt from the pure-ftpd manual:

pure-uploadscript – Automatically run an external program after a successful upload

pure-uploadscript [-p ] [-B] [-g ] [-h] -r [-u ]

So the program to run in our case can be a simple Bash script I’m going to call


banned_extensions="zip tar rar";

for ext in ${banned_extensions};
count=$(echo ${uploaded_file}|grep -i ${ext}$|wc -l);
if [ "${count}" -gt "0" ];
rm -f ${uploaded_file}; # File with banned extension detected. Delete it.

So you start the program in the background like this:

pure-uploadscript -p /var/run/ -B -r /root/

That’s all folks.

Write a Comment


  1. Thank you for sharing this!

    what does “pure-uploadscript -p /var/run/ -B -r” do anyway?

  2. Don’t forget to pass the script name to it (/root/ comes after the -r) like this:

    pure-uploadscript -p /var/run/ -B -r /root/

    The command waits for the FTP user to upload a file. As soon as the user uploads the file(s), pure-uploadscript runs the /root/ script, which in turn checks against a list of banned extensions. If the extensions match (tar zip rar), it removes the file from the uploaded folder.

    I hope this makes sense.


  • two day diet japan lingzhi August 9, 2009

    two day diet japan lingzhi…

    Link exchange is nothing else but it is simply placing the other person web site link on your page at proper place and other person will also do same for you….

  • URL August 9, 2009

    … [Trackback]…

    […] There you will find 87749 more Infos: […]…