Search Posts

How to setup FTP Server on centos 7.3(VSFTP)

Setting up FTP Server on Centos 7.3:

Ftp server is used to exchange files between computers over network.

Setup FTP server on Centos 7:-

Step1:- Updating Repository and installing VSFTP package

[root@newdelhihosting ~] # yum check-update

If update is available update the server and reboot it.

[root@newdelhihosting ~] # yum -y install vsftpd
Resolving Dependencies
--> Running transaction check
---> Package vsftpd.x86_64 0:3.0.2-22.el7 will be installed
--> Finished Dependency Resolution

Running transaction
Installing : vsftpd-3.0.2-22.el7.x86_64 1/1
Verifying : vsftpd-3.0.2-22.el7.x86_64 1/1

Installed:
vsftpd.x86_64 0:3.0.2-22.el7

Complete!

Step2:Modifying the configuration files

After installation, you can find “vsftpd.conf” file under /etc/vsftpd/ which is the main configuration file for VSFTP.

Take a backup copy before making changes

[root@newdelhihosting~] # cp vsftpd.conf vsftpd.conf1

Now open the configuration file and make changes as below

[root@newdelhihosting~] # nano /etc/vsftpd/vsftpd.conf

Find for anonymous_enable=YES and change value to NO to disable anonymous FTP access.

anonymous_enable=NO

Uncomment the below line to restrict users to their home directory.

chroot_local_user=YES

Now, add the following lines at the end of file to enable passove mode and allow chroot writable

allow_writeable_chroot=YES
pasv_enable=Yes
pasv_min_port=30000
pasv_max_port=35000

Step 3 : Now restart vsftpd service and make it start automatically after reboot.

[root@newdelhihosting~] # systemctl restart vsftpd.service
[root@newdelhihosting~] # systemctl enable vsftpd.service

Step 4 : Enable firewall and add FTP service in firewall to allow ftp ports.

[root@newdelhihosting~] # systemctl enable firewalld.service
[root@newdelhihosting~] # firewall-cmd --permanent --add-service=ftp
[root@newdelhihosting~] # firewall-cmd --reload

Step 5 : Setup SEinux to allow ftp access to the users home directories.

[root@newdelhihosting~]# setsebool -P ftp_home_dir on

Step 6 : Now create an user for ftp access. Here /sbin/nologin shell is used to prevent shell access to the server.

[root@newdelhihosting~]# useradd -m webhostchennai -s /sbin/nologin
[root@newdelhihosting~]# passwd webhostchennai

Changing password for user webhostchennai.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.

Now, the user newdelhihosting can able to login FTP on port 21

You can use any FTP client for transferring the files.

Leave a Reply

Your email address will not be published. Required fields are marked *

Social media & sharing icons powered by UltimatelySocial

Enjoy this blog? Please spread the word :)