Steps to install and configure FTP(vsFTPd) in linux (Fedora, CentOS, RedHat, etc)


Vsftpd (Very Secure FTP Daemon) is an FTP server for UNIX-like systems, including CentOS / RHEL / Fedora and other Linux distributions. It supportsIPv6, SSL, locking users to their home directories and many other advanced features.
In this guide you will learn:
  1. Setup vsftpd to Provide FTP Service.
  2. Configure vsftpd Basic.
VSFTPD offer security, performance and stability over other servers. A quick list of vsftpd features:
  1. Virtual IP configurations
  2. Virtual users
  3. Run as standalone or inetd / xinetd operation
  4. Per-user configuration
  5. Bandwidth throttling
  6. Per-source-IP configurability
  7. Per-source-IP limits
  8. IPv6 ready
  9. Encryption support through SSL integration
  10. And much more.

Step 1: Install Vsftpd FTP Server
Install the vsftpd package via yum command:
# yum install vsftpd
Vsftpd Defaults
  1. Default port: TCP / UDP – 21 and 20
  2. The main configuration file: /etc/vsftpd/vsftpd.conf
  3. Users that are not allowed to login via ftp: /etc/vsftpd/ftpusers
Basic Vsftpd commands on RHEL/CentOS/Fedora
Start Vsftpd Service :
# service vsftpd start
 Stop Vsftpd Service :
# service vsftpd stop
Restart Vsftpd Service :
# service vsftpd restart
Make Vsftpd Service auto start on boot up :
# chkconfig vsftpd on
Or
# chkconfig --levels 345 vsftpd on
 Edit the vsftp.conf
# vi /etc/vsftpd/vsftpd.conf
Step 2: Configure Vsftpd
We don’t want anonymous login:  # in 12th line line
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: #in 95th and 96th line
chroot_local_user=YES
chroot_list_enable=YES
#in 98th line
chroot_list_file=/etc/vsftpd/chroot_list
 set umask to 022 to make sure that all the files (644) and folders (755) you upload get the proper permissions.
local_umask=022
# in 51st line line( for upload/download logging)(optional)
xferlog_file=/var/log/vsftpd.log
Or Turn off standard ftpd xferlog log format:
xferlog_std_format=NO
Turn on verbose vsftpd log format. The default vsftpd log file is /var/log/vsftpd.log:
log_ftp_protocol=YES
# in 58th  line( set when an idle session time-outs, in seconds) (optional)
idle_session_timeout=1000
Create warning banners for all FTP users:
banner_file=/etc/vsftpd/issue
In 84th line(set your banner) (optional)
ftpd_banner=Welcome to servercomputing ftp service.
Allow ascii mode #in 80th & 81st line
ascii_upload_enable=YES
ascii_download_enable=YES
Use localtime
use_localtime=YES
# in 104th line
ls_recurse_enable=YES
#Add the following below line to limit transfer speed to 1MB/sec(optional)
local_max_rate=1000000
max_clients=5                                           #add to allow maximum 5 connections at a time(optional)
listen_port=200                                         # This is the method to change ftp port number(optional)
That basic configuration is complete.

Step 3: create users for ftp access(eg: danny)

[root@server ~#]useradd danny
OR
use the below command to create the user in nologin shell(recommended)
[root@server ~#]useradd -s /sbin/nologin danny

Step4: (create a new chroot_list file and add danny) add user danny to file to allow ftp access

[root@server ~#]vi /etc/vsftpd/chroot_list
#add the user ‘james’ to the file
danny
#save the chroot_list file. (u can add more users to use ftp by adding usernames to “chroot_list” one by one downwards)

If You get 500 OOPS error from vsftpd

Disabling SELinux:
# vi /etc/selinux/config
In this file set the option to disabled.
SELINUX=disabled
If SELINUX is rearing its ugly head on the server, this can be a problem. Check your current SELINUX status and disable it if necessary:
Setting SELinux for ftp access:
# getsebool -a | grep ftp
This will list a group of ftp boolean options, ftp_home_dir will by default be off. Set it on by
# setsebool -P ftp_home_dir on
This might take a min or two, wait till the prompt comes back. You can check by using the getseboolcommand again. If you need both local and virtual users then use the instructions in the next section.