How to Install and configure ftp server with user based authentication in centos 7/8 , Redhat 7/8 , Fedora

Share on :

How to Install and configure FTP server with user-based authentication in centos 7/8 , Redhat 7/8 , Fedora

Ftp is one of the best way to share files over the network. We can setup user-based authentication to secure our FTP server from unwanted access.In this blog we are going to user vsftp( very secure file transfer protocol ) to setup user-based authentication on our FTP server.

1) Install the VsFtp (Very Secure File Transfer Protocol) Package :-

——< for Centos 7,8 / Rhel 7,8 >——
yum install vsftpd -y
——-< Fedora >——
dnf install vsftpd -y

2) Open the configuration file of vsftp server and disable anonymous access by default ftp is set to anonymous access.

vim /etc/vsftpd/vsftpd.conf
press i to get into insert mode
# Example config file /etc/vsftpd/vsftpd.conf
#
# The default compiled in settings are fairly paranoid. This sample file
# loosens things up a bit, to make the ftp daemon more usable.
# Please see vsftpd.conf.5 for all compiled in defaults.
#
# READ THIS: This example file is NOT an exhaustive list of vsftpd options.
# Please read the vsftpd.conf.5 manual page to get a full idea of vsftpd’s
# capabilities.
#
# Allow anonymous FTP? (Beware – allowed by default if you comment this out).
anonymous_enable=NO
#
# Uncomment this to allow local users to log in.
# When SELinux is enforcing check for SE bool ftp_home_dir
local_enable=YES
#
# Uncomment this to enable any form of FTP write command.
write_enable=YES
#
#Add the following parameters in the end of the file. this parameters will provide security to your FTP server. In such a way that the FTP user will only be able to browser the FTP directory only
chroot_local_user=YES
after making changes in the file press escape from keyboard and press :wq! to write and quite from file.

3) Creating user for FTP access.

useradd ftpuser
passwd ftpuser

4) Start and enable the service.

systemctl start vsftpd
systemctl enable vsftpd

5) Apply the firewall rule

firewall-cmd –permanent –add-service=ftp
firewall-cmd –reload

6) Open your browser
ftp://<your_ip>  and pass your user credentials .

Our Ftp server is up and running now we will upload file to it to share.

Note: The Home directory of the user ftpuser is what we will see on the web browser so we need to add our files to share to the home directory of ftpuser.

The home directory of ftpuser is /home/ftpuser
so here we need to upload file here to share. copy or put your file to /home/ftpuser to share.
After you upload file to /home/ftpuser make sure you set the SELinux context also as in redhat, centos, fedora by default SELinux is enforcing. the SELinux context for the FTP file share is “public_content_t”. you can just run the following command to update the context on the uploaded files.

restorecon -vvRF /var/ftp

We have configured FTP server successfully.
Now, let’s move to the client side.

Ftp Clients:-

The Clients in the server network can access the FTP server just by opening their web server and searching FTP:// and passing the username and password

or the Clients can even access it by CLI (terminal) by installing FTP client package.

——< for Centos 7,8 / Rhel 7,8 >——
yum install ftp -y
——-< Fedora >——
dnf install ftp -y

After we install the FTP client package we can access the FTP server by terminal.

ftp 192.168.122.154
Connected to 192.168.122.154 (192.168.122.154).
220 (vsFTPd 3.0.2)
Name (192.168.122.154:root):ftpuser
331 Please specify the password.
Password: pass the password of FTP user
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> ls
227 Entering Passive Mode (192,168,122,154,54,89).
150 Here comes the directory listing.
226 Directory send OK.
ftp>

For more detailed Explanation Watch our YouTube Video


Share on :