Install and Configure FTP Server On CentOS, RHEL, Scientific Linux 6.5/6.4/6.3

VSFTPD (very secure FTP daemon) is an FTP server for Unix like systems including linux. it is a default

FTP server in ubuntu, centos,fedora and many other destro of linux.

You can execute below command to install this daemon:

yum install vsftpd ftp -y

vi /etc/vsftpd/vsftpd.conf
[…]
## Set to “NO” ##
anonymous_enable=NO
## Uncomment ##
ascii_upload_enable=YES
ascii_download_enable=YES
## Uncomment – Enter your Welcome message – This is optional ##
ftpd_banner=Welcome to UNIXMEN FTP service.
## Add at the end of this file ##
use_localtime=YES

We have to create users to login for sharing or using the services.
Create FTP users

By default, root user is not allowed to login to ftp server for security purpose. So let us create a testing user called “prinsa” with password “centos”:

# useradd prinsa
# passwd prinsa

Connecting to FTP server

Now let us try to connect to FTP server itself with user “prinsa”:

# ftp 192.168.1.101
Connected to 192.168.1.101 (192.168.1.101).
220 Welcome to ns2.raaz.com FTP service.
Name (192.168.1.101:root): prinsa
331 Please specify the password.
Password:
500 OOPS: cannot change directory:/home/prinsa
Login failed.
ftp>
Probably you will get an error like “500 OOPS: cannot change directory”.

This is because your SELinux restricts the user to log in to ftp server. So let us update the SELinux boolean values for FTP service:

# setsebool -P ftp_home_dir on
Now try again to login to FTP server:

# ftp 192.168.1.101
Connected to 192.168.1.101 (192.168.1.101).
220 Welcome to ns2.raaz.com FTP service.
Name (192.168.1.101:root): prinsa
331 Please specify the password.
Password:
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp>
Now you will be able to login to FTP server without any problems.

Client side configuration

Let me try to log in to the FTP server from my Ubuntu client system.

$ ftp 192.168.1.101
ftp: connect: No route to host
ftp>
You might see the above error like “ftp:connect:No route to host”. To resolve this error, allow the default ftp port “21” through your firewall or router. In the server side, do the following.

Edit file /etc/sysconfig/iptables,

# vi /etc/sysconfig/iptables
Add the following lines.

[…]
-A INPUT -m state –state NEW -m tcp -p tcp –dport 21 -j ACCEPT
[…]
Save and exit the file. Restart iptables now:

# service iptables restart
Now try again from the client system to login to FTP server:

$ ftp 192.168.1.101
Connected to 192.168.1.101.
220 Welcome to UNIXMEN FTP service.
Name (192.168.1.101:sk): prinsa
331 Please specify the password.
Password:
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp>
Boom!! It’s working now.

Working from command-line mode might be little bit annoying to newbies. So let us install a graphical FTP client called Filezilla to get things done quite easier:

$ sudo apt-get install filezilla
For RHEL based systems, you can install filezilla using following command:
vi /etc/sysconfig/iptables-config
Find the line IPTABLES_MODULES=” “ and change this to IPTABLES_MODULES=”ip_conntrack_ftp”:

# Load additional iptables modules (nat helpers)
# Default: -none-
# Space separated list of nat helpers (e.g. ‘ip_nat_ftp ip_nat_irc’), which
# are loaded after the firewall rules are applied. Options for the helpers are
# stored in /etc/modprobe.conf.
IPTABLES_MODULES=”ip_conntrack_ftp”
[…]
# yum install filezilla

service iptables save
service iptables restart

Rajkishor Maharjan has written 17 articles