How to Install and Configure FTP Server in CentOS/RHEL
The File Transfer Protocol’s purpose is the platform independent data transfer of the internet, it is based on a server/client architecture. A FTP connection involves four steps:
The first two letters of vsftpd stand for “very secure” and the program was built to have strongest protection against possible FTP vulnerabilities. It supports many features which are very much missed on other FTP-servers. Some of them are:
Install Required Packages
First install require packages (vsftpd, rpcbind and xinetd) using the following command :
# yum install vsftpd rpcbind xinetd -y
Start services
Start all the services and also make all these services auto start at boot :
# service vsftpd start # service xinetd start # service rpcbind start # chkconfig vsftpd on # chkconfig xinetd on # chkconfig rpcbind on
Create New user and file
Create the a new ftp user and set password :
# useradd techoism # passwd techoism
Login with ftp user on terminal and create a new files.
# su - ftpuser # echo "This file is created for RHEL 6 ftp server > ftpfiles
Login and Test with ftp user
login from user account and download the files :
# ftp 192.168.78.128
Connected to 192.168.78.128. 220 (vsFTPd 2.2.2) User (192.168.78.128:(none)): techoism 331 Please specify the password. Password: 230 Login successful. ftp> get ftpfiles 200 PORT command successful. Consider using PASV. 150 Opening BINARY mode data connection for ftpfiles (42 bytes). 226 Transfer complete. ftp: 42 bytes received in 0.00Seconds 42000.00Kbytes/sec. ftp> quit 221 Goodbye.
Note: By default root has no right to login the vsftpd server.
# ftp 192.168.78.128
Connected to 192.168.78.128. 220 (vsFTPd 2.2.2) User (192.168.78.128:(none)): root 530 Permission denied. Login failed. ftp>
Provied root user access
The file ftpusers(/etc/vsftpd/ftpusers)contains a list of users that may not login using the File Transfer Protocol (FTP) server. Remove or comment out the line for user “root”. Users whose name are set in this file will not allowed to login from ftp.
# vi /etc/vsftpd/ftpusers
# Users that are not allowed to login via ftp #root bin daemon adm lp sync shutdown halt mail news uucp operator games nobody
The file user_list(/etc/vsftpd/user_list)contains a list of users that may login or not login using the File Transfer Protocol (FTP) server. If userlist_deny=NO, only allow users in this file ,If userlist_deny=YES (default), never allow users in this file. Remove or comment out the line for user “root”. Users whose names are set in this file are also not allowed to login from ftp even they are not prompt for password.
# vi /etc/vsftpd/user_list
# vsftpd userlist # If userlist_deny=NO, only allow users in this file # If userlist_deny=YES (default), never allow users in this file, and # do not even prompt for a password. # Note that the default vsftpd pam config also checks /etc/vsftpd/ftpusers # for users that are denied. #root ftpuser bin daemon adm lp sync shutdown halt mail news uucp operator games nobody
Login with root User
Root are now allowed to access the ftp server.
# ftp 192.168.78.128
Connected to 192.168.78.128. 220 (vsFTPd 2.2.2) User (192.168.78.128:(none)): root 331 Please specify the password. Password: 230 Login successful. ftp> quit 221 Goodbye.
FTP banner
You can set login banner for ftp server also. Uncomment ftpd_banner and customize the login banner string as below :
# vi /etc/vsftpd/vsftpd.conf
# You may fully customise the login banner string: ftpd_banner=Welcome to Techoism.com FTP server
Restart the ftp service :
# service vsftpd restart
Try login to ftp server. Check the banner, it will appear before user login as below :
# ftp 192.168.78.128
Connected to 192.168.78.128. 220 Welcome to Techoism.com RHEL6 FTP server User (192.168.78.128:(none)):
Enjoy it!