Tuesday, July 7, 2015

How to restrict file types using sftp/vsftp?

Is it possible to restrict file types using sftp/vsftp in Linux?
I want client can only upload csv, log, xls,txt type files.


Depending on the use case, there are plenty of ways to address getting rid of unwanted files. The "cheap" way is to have a cron job run every 5 minutes that removes unwanted files. Or we can run a cleanup after a session ends. Or use inotify and run jobs as a file is created etc. Combined with FS quotas you can block a user from uploading very large files etc.

But remember - file system extensions means nothing in Linux. And well, the same goes for Windows actually. I can take my shell script and name it "myscript.txt" and your check would succeed.

So I would probably look at other options if you're trying to make sure you only process valid files.

No comments:

Post a Comment