In this post, We are going to learn in detail about What is FTP Server? and Why we need FTP server?
What is Ftp Server?
Ftp server stands for File transfer Protocol. Defination on ftp server explain everything in full form of ftp.
It is used for transferring files from one server to another via secure way.
Ftp is TCP based service and there is no UDP component for FTP.
FTP utilizes two port one is command port i.e. 21 and other is data port i.e. 20.
Why we need FTP Server?
FTP Server is basically using for data transfer. We need ftp to provide secure access on server codebase to developers or also for clients.
As i am working as linux admin lots of time client need ftp access to codebase directory on server to transfer some media files or to work on some code so that time ftp is very useful to provide access in secure way. Here secure way means we can use another port no. instead of default port no. which is easy to guess and also we can whitelist ftp port for Client office only or for specific public ip. This way ftp help to manage data transfer process very well.
Now follow the below steps to create ftp user and installation of ftp server.
On Centos server, we can install ftp server with the yum command which is easy way to install ftp service.
yum install vsftpd
Most of centos server IPtabels are in running state so if we don't need iptables then stop this using below command otherwise it will block our ftp port on server.
service iptables stop
After vsftpd service installation we can use below commads to start,stop and restart vsftpd service,
/etc/init.d/vsftpd start | stop | restart | status
Now we create FTP user which will be able to access desired directory on server
useradd testftp [useradd use to create user on server]
passwd testftp123 [passwd use to setup passwd for user]
After ftp user creation, we can set path of data directory which would be accessible by ftp user this is very important step for security resons otherwise ftp user able to view all server files.
So to set path we need to edit vipw file which is located under "/etc/passwd" directory.
vipw or vim /etc/passwd [Both way we can access passwd file on server]
above line has different fields i.e.
so we just changed the DIRECTORY_PATH to our desired path which we want to access through ftp.
After providing path we need to give access to ftp user to create,update,delete file in provided directory. For this we need to do setfacl for ftp user.
make sure before using setfacl give or add "acl" in /etc/fstab file on partition where we using setfacl permission.
Use below setfacl command to grant permission for directory,
setfacl -Rm u:testfp:rwx /var/www/htm
[getfacl used to check permission on directory]
Now test ftp user from client machine by using command or you can use Filezilla application for same.
Important changes make in vsftpd.conf file and restart the vsftpd service.
1. Anonymous_enble = NO [ default is YES change to NO for security ]
2. Local_enable = YES [ Allow local user to access ftp ]
3. Write_enable = YES [ Allow read write access for ftp user]
4. Xferlog_enable = YES [ Help to generate ftp logs ]
5. Chown_uploads = YES [ by default commented, helpful to set user of remaining file for eg. If we have user apache for all files and we provide testftp user for ftp client when client upload file it will create as testftp because we provide testftp if we want file to uploaded or changed must create with apache user we can use this parameter. ]
6. Chown_username = apache [ file will be created or uploded with apache user ]
7. Chroot_local_user = YES [ help to create chroot jail for ftp user helpful for security ]
8. Listen = YES [ listen ipv4 port]
Types of FTP :