Category Archives: FTP

Setup a FTP server on CentOS6

So it’s close to a half a year since I started maintaining my own CentOS server, but did not set up a FTP server on it, therefore file transfers were quite tedious to accomplish.

So I went on googling about a lightweight linux ftp server and I stumbled upon vsftp and I thought I could make use of it as a service (vsftpd).
But before you think about setting a FTP server you might want to check on whether or not you already have one already opened (which was in my case).
You could check for the processes running the following command:
netstat -tulnp|grep :21

If you find that you have one already functioning and running you might want to check how to configure it and make use of it otherwise you could make use of vsftpd.
First proceed with installing the server which is as simple as:
yum install vsftpd
Then configure it for your need. You might want to make it as secure as possible, if that’s the case follow these steps then take a closer look at the reference.
Edit the configuration file /etc/vsftpd/vsftpd.conf with your editor of choice and modify the following:

We don’t want anonymous login:

anonymous_enable=NO

Enable local users:

local_enable=YES

The ftpuser should be able to write data:

write_enable=YES

Port 20 need to turned off, makes vsftpd run less privileged:

connect_from_port_20=NO

Chroot everyone:

chroot_local_user=YES

set umask to 022 to make sure that all the files (644) and folders (755) you upload get the proper permissions.

local_umask=022

Then prepare a user for FTP use:

useradd -d /var/www/path/to/your/dir ftpuser
passwd ftpuser
And give it access to the FTP root directory:
chown -R ftpuser /var/www/path/to/your/dir
sudo chmod 775 /var/www/path/to/your/dir

When ready you can start your service with:
service vsftpd start
and make it automatically start at boot time with:
chkconfig vsftpd on