How to Setup an FTP Server with vsftpd on CentOS 7

29/12/2020
Chưa phân loại
vsftpd is an open source and lightweight FTP server solution. It is very fast, secure and stable. The configuration of vsftpd is very simple and straightforward.

In this article, I am going to show you how to install and access the vsftpd FTP server on CentOS 7. So, let’s get started.

Installing vsftpd:

vsftpd is available in the official package repository of CentOS 7. So, you can easily install it with the YUM package manager.

First, update the YUM package repository cache with the following command:

$ sudo yum makecache

The YUM package repository cache should be updated.

Now, install vsftpd with the following command:

$ sudo yum install vsftpd

Now, press y and then press <Enter> to continue.

vsftpd should be installed.

Now, check whether the vsftpd service is running with the following command:

$ sudo systemctl status vsftpd

As you can see, the vsftpd service is not running or inactive.

To start the vsftpd service, run the following command:

$ sudo systemctl start vsftpd

Now, check the status of the vsftpd service again.

$ sudo systemctl status vsftpd

As you can see, vsftpd service is running.

Now, you should add vsftpd service to the system startup so that it will start automatically on system boot.

To add the vsftpd service to the system startup, run the following command:

$ sudo systemctl enable vsftpd

vsftpd service should be added to the system startup.

Configuration Files of vsftpd:

On CentOS 7, all the vsftpd configuration files are in the /etc/vsftpd directory as you can see in the screenshot below.

The main configuration file is /etc/vsftpd/vsftpd.conf. If you want to configure vsftpd, most of the time you will be spending on modifying this file.

The main configuration file /etc/vsftpd/vsftpd.conf contains a lot of comments which is helpful when you configure vsftpd, but it makes it hard to see what configuration options are enabled. So, I recommend you keep a backup copy of the original configuration file and remove all comments from the /etc/vsftpd/vsftpd.conf file. This way, you will be able to take a look at the comments whenever you need any help configuring vsftpd and still have a clean configuration file which is easy to work with.

To make a backup copy (I will call it /etc/vsftpd/vsftpd.conf.backup) of the original /etc/vsftpd/vsftpd.conf file, run the following command:

$ sudo cp -v /etc/vsftpd/vsftpd.conf /etc/vsftpd/vsftpd.conf.backup

Now, remove all the comments from the original /etc/vsftpd/vsftpd.conf configuration file with the following command:

$ sudo egrep -v ‘^.*#’ /etc/vsftpd/vsftpd.conf.backup | sudo tee /etc/vsftpd/vsftpd.conf

As you can see, the original configuration file now looks very clean.

Accessing the FTP Server:

The default configuration of vsftpd on CentOS is good enough. By default, vsftpd is configured in a way that lets only the login users on CentOS 7 to access their home directories via FTP.

To access your FTP server, you can use the command line lftp client program or any graphical FTP client programs such as FileZilla. I am going to use lftp command line FTP client in this article. I will use the same CentOS 7 machine for testing.

lftp is available in the official package repository of CentOS 7.

To install lftp, run the following command:

$ sudo yum install lftp

Now, press y and then press <Enter> to continue.

lftp should be installed.

Now, find the IP address of your FTP server as follows:

$ ip a

As you can see, the IP address of my FTP server is 192.168.21.133. Your IP address will be different. So, make sure to replace it with yours from now on.

Now, to try to access the FTP server as your login user as follows:

$ lftp -u USERNAME IP_ADDR

Here, USERNAME is the username of your login user that you want to log in to the FTP server as and IP_ADDR is the IP address of your FTP server.

Now, type in the password of your login user and press <Enter>.

You should be connected.

As you can see, all the directories and files of my HOME directory is listed. So, it works.

Adding New FTP Users:

As the default configuration of vsftpd lets only the login users access their home directories via FTP, to add a new FTP user, all you have to do is to add a new login user on your CentOS 7 machine.

To add a new user linda, run the following command:

$ sudo adduser -m linda

Now, set a password for the user linda with the following command. Note that, this is also the FTP password for the user linda.

$ sudo passwd linda

Now, type in a password for the user linda and press <Enter>.

Now, re-type the password and press <Enter>.

The password should be set.

As you can see, I can access the HOME directory of the user linda that I’ve just created.

Opening FTP Ports:

Now that everything is working, you can open the FTP ports so that other people can access it.

To do that using the default firewall program (firewalld) of CentOS 7, run the following command:

$ sudo firewall-cmd –zone=public –add-service=ftp –permanent

Now, reload the firewall for the changes to take effect with the following command:

$ sudo firewall-cmd –reload

So, that’s how you install and access the vsftpd FTP server on CentOS 7. Thanks for reading this article.

Sandclock IDC thành lập vào năm 2012, là công ty chuyên nghiệp tại Việt Nam trong lĩnh vực cung cấp dịch vụ Hosting, VPS, máy chủ vật lý, dịch vụ Firewall Anti DDoS, SSL… Với 10 năm xây dựng và phát triển, ứng dụng nhiều công nghệ hiện đại, Sandclock IDC đã giúp hàng ngàn khách hàng tin tưởng lựa chọn, mang lại sự ổn định tuyệt đối cho website của khách hàng để thúc đẩy việc kinh doanh đạt được hiệu quả và thành công.
Bài viết liên quan

How to install MPV Video Player 0.25.0 on Ubuntu 17.04, Ubuntu 16.04, Linux Mint

MPV Video Player 0.25.0 recently released, is a free, open source, and cross-platform movie player based on MPlayer and...
28/12/2020

Làm việc với lệnh Find và Locate

1. Lệnh Find find đường_dẫn -name kí_tự_cần_tìm Lệnh này sẽ cung cấp cho bạn một danh...
30/12/2020

Google DNS Tutorial

On 3 December 2009, Google announced its free alternative Domain Name System (DNS) service, Google Public DNS, which can...
28/12/2020
Bài Viết

Bài Viết Mới Cập Nhật

Hướng dẫn chuyển đổi windows server windows evaluation to standard và active windows server 2008 + 2012 + 2016 + 2019
26/10/2021

How to Update Ubuntu Linux
24/10/2021

Squid Proxy Manager cài đặt và quản lý Proxy Squid tự động trên ubuntu
20/10/2021

Hướng dẫn cài đặt Apache CloudStack 4.15.2.0
19/10/2021

Hướng dẫn ký file PDF bằng chữ ký số (chữ ký điện tử) và sửa lỗi mới nhất 2021 foxit reader
19/10/2021