Search Suggest

How to Setup FTP/VSFTP server in linux RHEL/CentOS- 5.X/6.X

VSFTPD stands for Very Secure FTP Daemon is designed for uploading and downloading the data on server. It helps user to upload and download data from server to client in any location wheter user is in Local Aread Network or Wide Area Network .

Server information

Operating System: CentOS 6.5
Server IP Address: 10.10.1.7
Package name : vsftpd
configuration file : /etc/vsftpd/vsftpd.conf
Document root : /var/ftp/pub
Service name : vsftpd
FTP Server listen on :  21
Selinux Status  : disabled
Iptables Status : Flush and save

Cleint Information

Operating System : Any Windows or Linux
Client IP Address : 10.10.1.20
Client Software : Filezilla

Above are server and client information . In this toutorial you will learn how to install and configure  FTP/VSFTP Server in simple step by step.

Show SeLinux Status

[root@ftpserver ~]# getenforce
Disabled

If you are unable to disable SeLinux Policy then edit file

[root@ftpserver ~]# vim /etc/sysconfig/selinux

SELINUX=disabled

Flush Iptables service and save

[root@ftpserver ~]# iptables –F
[root@ftpserver ~]# service iptables save
[root@ftpserver ~]# service iptables restart

Install VSFTPD package on server

[root@ftpserver ~]# yum install vsftpd -y

If you want to install ftp cleint package on server then install with below command.

[root@ftpserver ~]# yum install ftp -y

After installation of server and client package on server , you can now configure vsftpd server.

Configure vsftpd server

Choose any file editor in which you are comfortable to modify configuration file.

You can configure vsftpd server in two way.

1. Anonymous configuration  ( For public access in which no user name and password required)
2. User based configuration  ( For authentication access, in which user name and password requred)

Anonymos configuration

[root@ftpserver ~]# vim /etc/vsftpd/vsftpd.conf

#Search below parameter in config file.

anonymous_enable=YES    (this prameter allow to share data in pub direcory )

Restart vsftpd service to take effect.

[root@ftpserver ~]# service vsftpd restart

Permanently on vsftpd server on startup

[root@ftpserver ~]# chkconfig vsftpd on

Access FTP Server from Client Machine

You can access FTP server using Windows Explorer, Any of Internet Browser or through FileZilla Software.
Open Browser and type url  ftp://10.10.1.7



You have successfully access ftp server. Now you can only download data.

################################################################################

Configure User based FTP Server

You can create user and share with your client. There they will get home directory of user data.
Create one or more user
[root@ftpserver ~]# useradd test1
[root@ftpserver ~]# useradd test2

Set password of user
[root@ftpserver ~]# passwd test1
[root@ftpserver ~]# passwd test2

Configure user based FTP Server

[root@ftpserver ~]# vim /etc/vsftpd/vsftpd.conf

anonymous_enable=NO   (Change YES to NO if you configure user based FTP Server )
local_enable=YES
anon_upload_enable=YES
anon_mkdir_write_enable=YES


After changing in Config file , Restart ftp service.

[root@ftpserver ~]# service vsftpd restart


Now Access FTP Server from Client machine using FileZilla Software.

In software you need to put Server IP Address , User Name and password of user.



Successfully you have configured user based FTP server . 

One thing i have noticed in above ftp access, User can access their home directory using ftp access but also they are entering in "/" directory when user access ftp server using command line.

Access ftp server using command line



So, you need to restrict user to work on their home directory only . To perform this action we need enable Chroot Environment in ftp config file . We also call it Jail Environment .

Enable Chroot Environment 

[root@ftpserver ~]# vim /etc/vsftpd/vsftpd.conf

chroot_list_enable=YES
chroot_list_file=/etc/vsftpd/chroot_list
userlist_deny=NO

Create File "/etc/vsftpd/chroot_list" and put user inside .

[root@ftpserver ~]# vim /etc/vsftpd/chroot_list
test1

Also put user inside file which have FTP server access.

[root@ftpserver ~]# vim /etc/vsftpd/user_list
test1

Now Finally access FTP server from command line.



This is all about VSFTPD/FTP server in linux .. If you need more help in FTP server you can contact me @ salam843@gmail.com or you can comment below...

Đăng nhận xét