How to Setup VsFTPD Service with SSL/TLS on Linux CentOS 7 / RHEL 7 / Oracle Linux 7

Setup VsFTPD service

If you have your own dedicated server or virtual private server that run in linux operating system to host your website or blog, it is recommended to install and setup ftp Service in order to facilitate the transfer of files and update your website. Among the well-known FTP software is VsFTPD.

VsFTPD means “Very Secure FTP Daemon” is the free FTP for Linux and UNIX operating systems, which are very stable, fast and safe to use even if the server is in the internet.

Is ftp secure ?

Any server in the internet is vulnerable to intruders that may spying on data transfer and steal confidential information such as id and password if encryption is not configured.

In this article, I will share the basic steps to setup VsFTPD service with SSL/TLS encryption on CentOS 7, RHEL 7 and Oracle Linux 7 operating system.

Steps to Setup VsFTPD Service with SSL/TLS

1. Install and setup VsFTPD Service :

# yum install vsftpd -y

2. Add ftp user :

# useradd user1
# passwd user1
Changing password for user user1.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.

3. Now Edit VsFTPd configuration file /etc/vsftpd/vsftpd.conf :

See also  How to Restart Linux Network Service

Enable the following :

..
..
# 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
..
..

Optionaly. you can customize the banner :

..
..
# You may fully customise the login banner string:
ftpd_banner=Welcome to ehowstuff FTP service.
..
..

4. Create ssl and private directory :

# mkdir -p /etc/vsftpd/ssl
# mkdir -p /etc/vsftpd/ssl/private/

5. Create a SSL certificate using on of following command :

# openssl req -x509 -nodes -days 720 -newkey rsa:2048 -keyout /etc/vsftpd/ssl/private/vsftpd.key -out /etc/vsftpd/ssl/vsftpd.pem

You will be prompted with a series of question, which you answer as they appear :

Example :

# openssl req -x509 -nodes -days 720 -newkey rsa:2048 -keyout /etc/vsftpd/ssl/private/vsftpd.key -out /etc/vsftpd/ssl/vsftpd.pem
Generating a 2048 bit RSA private key
......................+++
..........................+++
writing new private key to '/etc/vsftpd/ssl/private/vsftpd.key'
-----
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [XX]:MY
State or Province Name (full name) []:Malaysia
Locality Name (eg, city) [Default City]:Kuala Lumpur
Organization Name (eg, company) [Default Company Ltd]:ehowstuff
Organizational Unit Name (eg, section) []:IT
Common Name (eg, your name or your server's hostname) []:centos7
Email Address []:admin@ehowstuff.local

6. Assign the permission :

# chmod 400 /etc/vsftpd/ssl/vsftpd.pem
# chmod 400 /etc/vsftpd/ssl/private/vsftpd.key

7. Edit vsftpd configuration file /etc/vsftpd/vsftpd.conf. Specify the location of our certificate and key files then add the following line at the bottom of vsftpd.conf :

..
..
# Add follows to the bottom
ssl_enable=YES
allow_anon_ssl=NO
force_local_data_ssl=YES
force_local_logins_ssl=YES

ssl_tlsv1=YES
ssl_sslv2=NO
ssl_sslv3=NO
rsa_cert_file=/etc/vsftpd/ssl/vsftpd.pem
rsa_private_key_file=/etc/vsftpd/ssl/private/vsftpd.key

8. Stop and Start VsFTPD Service and make it auto start at boot :

# systemctl stop vsftpd
# systemctl start vsftpd
# systemctl enable vsftpd

9. Check VsFTPD status :

# systemctl status vsftpd
vsftpd.service - Vsftpd ftp daemon
   Loaded: loaded (/usr/lib/systemd/system/vsftpd.service; enabled)
   Active: active (running) since Sat 2014-12-13 10:31:30 MYT; 34s ago
  Process: 20864 ExecStart=/usr/sbin/vsftpd /etc/vsftpd/vsftpd.conf (code=exited, status=0/SUCCESS)
 Main PID: 20865 (vsftpd)
   CGroup: /system.slice/vsftpd.service
           ââ20865 /usr/sbin/vsftpd /etc/vsftpd/vsftpd.conf

Dec 13 10:31:30 centos7.ehowstuff.local systemd[1]: Starting Vsftpd ftp daemon...
Dec 13 10:31:30 centos7.ehowstuff.local systemd[1]: Started Vsftpd ftp daemon.

10. From client PC, open filezilla and connect to your server and enter info, for encryption field, select “explicit FTP over TLS”.
vsftpd-centos7-1

See also  How to Check Concurrent user using Netstat Command on Linux Web Server

Click the check box “Always trust certificate in the future sessions.” Then clik OK to proceed.
vsftpd-centos7-2

I hope this article gives you some ideas and essential guidance on how to setup VsFTPD service with SSL/TLS encryption on CentOS 7, RHEL 7 and Oracle Linux 7 operating system.

Resources :

Comments

Leave a Reply

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